<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0080)http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170804&showall=true -->
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
<link rel="stylesheet" type="text/css" href="./OCPJP 6 - Exam Simulator  Practice Test IV_files/styles.php">
<link rel="stylesheet" type="text/css" href="./OCPJP 6 - Exam Simulator  Practice Test IV_files/styles(1).php">

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="http://www.whizlabs.com/examprep/theme/standard/styles_ie7.css" />
<![endif]-->
<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="http://www.whizlabs.com/examprep/theme/standard/styles_ie6.css" />
<![endif]-->


    <meta name="keywords" content="moodle, OCPJP 6 - Exam Simulator: Practice Test IV ">
    <title>OCPJP 6 - Exam Simulator: Practice Test IV</title>
    <link rel="shortcut icon" href="http://www.whizlabs.com/examprep/theme/ability-to-learn/favicon.ico">
    <!--<style type="text/css">/*<![CDATA[*/ body{behavior:url(http://www.whizlabs.com/examprep/lib/csshover.htc);} /*]]>*/</style>-->

<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/javascript-static.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/javascript-mod.php"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/overlib.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/overlib_cssstyle.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cookies.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/ufo.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/dropdown.js"></script>  

<script type="text/javascript" defer="defer">
//<![CDATA[
setTimeout('fix_column_widths()', 20);
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
function openpopup(url,name,options,fullscreen) {
  fullurl = "http://www.whizlabs.com/examprep" + url;
  windowobj = window.open(fullurl,name,options);
  if (fullscreen) {
     windowobj.moveTo(0,0);
     windowobj.resizeTo(screen.availWidth,screen.availHeight);
  }
  windowobj.focus();
  return false;
}

function uncheckall() {
  void(d=document);
  void(el=d.getElementsByTagName('INPUT'));
  for(i=0;i<el.length;i++) {
    void(el[i].checked=0);
  }
}

function checkall() {
  void(d=document);
  void(el=d.getElementsByTagName('INPUT'));
  for(i=0;i<el.length;i++) {
    void(el[i].checked=1);
  }
}

function inserttext(text) {
  text = ' ' + text + ' ';
  if ( opener.document.forms['theform'].message.createTextRange && opener.document.forms['theform'].message.caretPos) {
    var caretPos = opener.document.forms['theform'].message.caretPos;
    caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  } else {
    opener.document.forms['theform'].message.value  += text;
  }
  opener.document.forms['theform'].message.focus();
}

function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}
//]]>
</script>
    
		<style type="text/css">
	<!--
	#main {
		min-height: 500px;
		width: 988px;
		margin: auto;
		background:#fff;
	}
	#header {
		height: 90px;
		width: 988px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/header.gif);
	}
	#navi {
		float: left;
		height: 22px;
		width: 828px;
		padding: 10px 0pt 0pt 20px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_02.gif);
	}
	#navi2 {
		height: 32px;
		width: 140px;
		float: left;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/part3left.gif);
		text-align: left;
	}
	#left {
		float: left;
		min-height: 675px;
		width: 263px;
	}
	
	#leftinsertdiv {
		float: left;
		height: 58px;
		width: 263px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-left-down_04.gif);
	}
	
	#left3 {
		float: left;
		height: 617px;
		width: 21px;
		/*background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_05.gif);*/
	}
	
	#left4 {
		height: 58px;
		width: 242px;
		float: right;
	}
	#left5 {
		float: right;
		height: 62px;
		width: 242px;
	}
	#left6 {
		float: right;
		min-height: 160px;
		width: 242px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_06-19.gif);
	}
	#right {
		float: left;
		min-height: 601px;
		width: 725px;
		background:#fff;
	}
	#leftfooter {
		float: left;
		height: 159px;
		width: 263px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/footerdiv.gif);
		background-repeat:no-repeat;
	}
	#rightfooter {
		float: left;
		height: 50px;
		width: 725px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_10-53.gif);
		background-position:left bottom;
		background-repeat:no-repeat;
		padding-top:90px;
		background-color:#fff;
	}
	#rightfooter2 {
		float: left;
		height: 19px;
		width: 725px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_54.gif);
	}
	-->
	</style>
	
<link href="./OCPJP 6 - Exam Simulator  Practice Test IV_files/css.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

<script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/document_iterator.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/find_proxy.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/get_html_text.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/global_constants.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/name_injection_builder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/number_injection_builder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/string_finder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/change_sink.js"></script><meta name="document_iterator.js"><meta name="find_proxy.js"><meta name="get_html_text.js"><meta name="global_constants.js"><meta name="name_injection_builder.js"><meta name="number_injection_builder.js"><meta name="string_finder.js"><meta name="change_sink.js"><style charset="utf-8" type="text/css" id="">SPAN.skype_pnh_container SPAN.skype_pnh_mark{  display:none !important;}@media screen{SPAN.skype_pnh_print_container_1323210120{  display:none !important;}SPAN.skype_pnh_container, SPAN.skype_pnh_container *{background-attachment: scroll !important;background-color: transparent !important;background-image: none !important;background-position: 0px 0px ! important;background-repeat: no-repeat !important;border: 0px none !important;border-color: #000000 !important;border-style: none !important;border-width: 0 !important;border-left: 0 none #000000 !important;border-top: 0 none #000000 !important;border-right: 0 none #000000 !important;border-bottom: 0 none #000000 !important;border-left-color: #000000 !important;border-left-style: none !important;border-left-width: 0 !important;border-top-color: #000000 !important;border-top-style: none !important;border-top-width: 0 !important;border-right-color: #000000 !important;border-right-style: none !important;border-right-width: 0 !important;border-bottom-color: #000000 !important;border-bottom-style: none !important;border-bottom-width: 0 !important;border-collapse: separate !important;bottom: auto !important;clear: none !important;clip: auto !important;cursor: pointer !important;direction: ltr !important;display: inline !important;float: none !important;font-style: normal !important;left: auto !important;letter-spacing: 0 !important;list-style-image: none !important;list-style-position: outside !important;list-style-type: disc !important;overflow: hidden !important;overflow-x: hidden !important;overflow-y: hidden !important;padding: 0px 0px 0px 0px !important;padding-left: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;page-break-after: auto !important;page-break-before: auto !important;page-break-inside: auto !important;position: static !important;right: auto !important;table-layout: auto !important;text-align: left !important;text-decoration: none !important;text-indent: 0px !important;text-transform: none !important;top: auto !important;voice-family: inherit !important;white-space: nowrap !important;word-spacing: normal !important;z-index: 0 !important;  color: #49535A !important;  font-family: Tahoma, Arial, Helvetica, sans-serif !important;  font-size: 11px !important;  font-weight: bold !important;  height: 14px !important;  line-height: 14px !important;  margin-left: 0px !important;  margin-top: 0px !important;  margin-right: 0px !important;  margin-bottom: 0px !important;  vertical-align: baseline !important;  width: auto !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_fax SPAN.skype_pnh_right_span, SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_fax SPAN.skype_pnh_right_span{  background-position: -92px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_dropart_flag_span{  background-position: 0px 1px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_textarea_span{  background-position: -90px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_text_span{  visibility: hidden !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_dropart_flag_span{  background-position: 0px 1px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_textarea_span{  background-position: -160px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_text_span{  background-position: -160px 0px !important;  color: #FFFFFF !important;}SPAN.skype_pnh_container SPAN.skype_pnh_left_span{  background-position: 0px 0px !important;  width: 6px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_span{  background-position: -11px 0px !important;  width: 27px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_wo_arrow_span{  background-position: -130px 0px !important;  width: 18px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_flag_span{  background-position: 1px 1px !important;  width: 18px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_textarea_span{  background-position: -125px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_text_span{  padding-left: 5px !important;  background-position: -125px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_right_span{  background-position: -62px 0px !important;  width: 15px !important;}}@media print{SPAN.skype_pnh_print_container_1323210120{}SPAN.skype_pnh_container{    display:none !important;}}@media screen{SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_common *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_inactive_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_common *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_active_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_fax *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_inactive_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_fax *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_active_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_free_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_free_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_flag_span{  background-image: url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/flags.gif') !important;}}</style></head>
<!-- WANT URL-->

<body class="mod-quiz course-11 dir-ltr lang-en_utf8" id="mod-quiz-review" onload="MM_preloadImages(&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_07.gif&#39;,&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-over_05.gif&#39;);">


<div id="main">
  <div id="header"><br>
    <p class="headertxt">Call Us at <span class="skype_pnh_print_container_1323210120">+1-818-575-6625</span><span class="skype_pnh_container" dir="ltr" tabindex="-1"><span class="skype_pnh_mark"> begin_of_the_skype_highlighting</span>&nbsp;<span class="skype_pnh_highlighting_inactive_common" dir="ltr" skypeaction="skype_dropdown" title="Call this phone number in United States of America with Skype: +18185756625"><span class="skype_pnh_left_span" skypeaction="skype_dropdown" title="Skype actions">&nbsp;&nbsp;</span><span class="skype_pnh_dropart_span" skypeaction="skype_dropdown" title="Skype actions"><span class="skype_pnh_dropart_flag_span" skypeaction="skype_dropdown" style="background-position: -5849px 1px !important; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;</span><span class="skype_pnh_textarea_span"><span class="skype_pnh_text_span">+1-818-575-6625</span></span><span class="skype_pnh_right_span">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>&nbsp;<span class="skype_pnh_mark">end_of_the_skype_highlighting</span></span> | <a href="http://www.whizlabs.com/examprep/login/logout.php?sesskey=A3za88nMmO">Sign Out</a> | <a href="http://www.whizlabs.com/index.php?option=com_whizmart&view=cart">My Cart</a> | <a href="http://www.whizlabs.com/examprep/user/view.php">Change Password</a></p>
    <p class="txtheader">Welcome <a href="http://www.whizlabs.com/examprep">Flavio&nbsp;Vit !</a></p>
  </div>


  <div id="navi" class="breadcrumb"><h2 class="accesshide ">You are here</h2> <ul>
<li class="first"><a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/">Home</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/">My Account</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/course/view.php?id=11">OCPJP 6 - Exam Simulator</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/mod/quiz/view.php?id=2205">Practice Test IV</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> Review of attempt 1</li></ul>			<div class="navbutton">
				</div>  
  
  <div style="float:right; margin-right:60px;font-size:12px; font-weight:bold; color:#0460AD;">
  	</div>
  </div>

  <div id="navi2">
  <a href="http://www.whizlabs.com/examprep/eddy_report/performance_trak.php?cid=11" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(&#39;Image1&#39;,&#39;&#39;,&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/layerrollov.gif&#39;,1)"><img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/performace_history.gif" name="Image1" width="125" height="32" border="0" id="Image1"></a></div>
    <!-- END OF HEADER -->
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div><h2 class="main">Practice Test IV</h2><h2 class="main">Review of attempt 1</h2>
 



<div class="controls">
<div class="singlebutton"><form action="http://www.whizlabs.com/examprep/mod/quiz/view.php" method="get"><div><input type="hidden" name="id" value="2205"><input type="submit" value="Finish review"></div></form></div></div>
<table class="generaltable generalbox quizreviewsummary"><tbody>
<tr><th scope="row" class="cell">Started on</th><td class="cell">Monday,  19 December 2011, 09:30 AM</td></tr>
<tr><th scope="row" class="cell">Completed on</th><td class="cell">Monday,  19 December 2011, 11:58 AM</td></tr>
<tr><th scope="row" class="cell">Time taken</th><td class="cell">2 hours 27 mins</td></tr>
<tr><th scope="row" class="cell">Grade</th><td class="cell"><b>41.5</b> out of a maximum of 60 (<b>69</b>%)</td></tr>
<tr><th scope="row" class="cell">Feedback</th><td class="cell"><p>PASS: Keep it up!</p></td></tr>
</tbody></table>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%201%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5454" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                1      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which code fragment inserted at line 2 of the following code will yield an output of 54,567.68? <br><br>NumberFormat numberFormat = NumberFormat.getInstance(Locale.UK); <br>// line 2 <br>System.out.println(numberFormat.format(54567.678));</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5454_23259" name="resp5454_" type="radio" value="23259">        </td>
        <td class="c1 text correct">
          <label for="resp5454_23259">
            <span class="anun">a<span class="anumsep">.</span></span> numberFormat.setMaximumFractionDigits(2);            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5454_23260" name="resp5454_" type="radio" value="23260">        </td>
        <td class="c1 text ">
          <label for="resp5454_23260">
            <span class="anun">b<span class="anumsep">.</span></span> numberFormat.setFractionDigits(2);            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5454_23261" name="resp5454_" type="radio" value="23261">        </td>
        <td class="c1 text ">
          <label for="resp5454_23261">
            <span class="anun">c<span class="anumsep">.</span></span> numberFormat.setMinimumFractionDigits(2);            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5454_23262" name="resp5454_" type="radio" value="23262">        </td>
        <td class="c1 text ">
          <label for="resp5454_23262">
            <span class="anun">d<span class="anumsep">.</span></span> numberFormat.setDecimalDigits(2);            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5454_23263" name="resp5454_" checked="checked" type="radio" value="23263">        </td>
        <td class="c1 text ">
          <label for="resp5454_23263">
            <span class="anun">e<span class="anumsep">.</span></span> numberFormat.setMaximumDecimalDigits(2);            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>The NumberFormat.setMaximumFractionDigits() method sets the maximum number of digits allowed in the fraction portion of a number. <br><br>maximumFractionDigits must be &gt;= minimumFractionDigits. <br><br>If the new value for maximumFractionDigits is less than the current value of minimumFractionDigits, then minimumFractionDigits will also be set to the new value. <br><br>Choice C is incorrect because it sets the minimum number of digits. All the other choices are incorrect because there are no such methods. <br><br>Reference: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html">http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%202%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5455" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                2      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the given code? <br><br>String str = "aaaaaaaaabb"; <br>String[] s=str.split("a{3}"); <br>System.out.println(s.length);</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5455_23264" name="resp5455_" type="radio" value="23264">        </td>
        <td class="c1 text ">
          <label for="resp5455_23264">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5455_23265" name="resp5455_" type="radio" value="23265">        </td>
        <td class="c1 text ">
          <label for="resp5455_23265">
            <span class="anun">b<span class="anumsep">.</span></span> Exception at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5455_23266" name="resp5455_" checked="checked" type="radio" value="23266">        </td>
        <td class="c1 text ">
          <label for="resp5455_23266">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 0            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5455_23267" name="resp5455_" type="radio" value="23267">        </td>
        <td class="c1 text ">
          <label for="resp5455_23267">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5455_23268" name="resp5455_" type="radio" value="23268">        </td>
        <td class="c1 text ">
          <label for="resp5455_23268">
            <span class="anun">e<span class="anumsep">.</span></span> Prints 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5455_23269" name="resp5455_" type="radio" value="23269">        </td>
        <td class="c1 text ">
          <label for="resp5455_23269">
            <span class="anun">f<span class="anumsep">.</span></span> Prints 3            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5455_23270" name="resp5455_" type="radio" value="23270">        </td>
        <td class="c1 text correct">
          <label for="resp5455_23270">
            <span class="anun">g<span class="anumsep">.</span></span> Prints 4            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice G is the correct answer. <br><br>The String.split() method splits a string around matches of the given regular expression. The return value is a String array containing the tokens.<br><br>In this case we split on the expression "a{3}" and the tokens are stored in the array s. Here, the regular expression a{3} is searching for three occurrences of the letter "a" in a row. <br><br>To match a pattern exactly n number of times, we specify the number inside a set of braces. <br><br>Since G is correct, the other choices are automatically incorrect. <br><br>Want to know more about the split method? Refer to: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%203%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5456" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                3      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile and run the following code? <br><br>public class WrapDemo <br>{<br>
<div style="margin-left: 40px;"> public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">String str = "19"; // line 1 <br>str.concat(".5"); // line 2 <br>Double d = new Double(str); // line 3 <br>Long l = new Long(str); // line 4 <br>System.out.println(d.intValue() + d.doubleValue() + l.doubleValue()); //line 5 <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5456_23271" name="resp5456_" type="radio" value="23271">        </td>
        <td class="c1 text ">
          <label for="resp5456_23271">
            <span class="anun">a<span class="anumsep">.</span></span> It will print - 57.5            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5456_23272" name="resp5456_" checked="checked" type="radio" value="23272">        </td>
        <td class="c1 text correct">
          <label for="resp5456_23272">
            <span class="anun">b<span class="anumsep">.</span></span> It will print - 57.0            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5456_23273" name="resp5456_" type="radio" value="23273">        </td>
        <td class="c1 text ">
          <label for="resp5456_23273">
            <span class="anun">c<span class="anumsep">.</span></span> It will print - 58.0            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5456_23274" name="resp5456_" type="radio" value="23274">        </td>
        <td class="c1 text ">
          <label for="resp5456_23274">
            <span class="anun">d<span class="anumsep">.</span></span> Compilation error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5456_23275" name="resp5456_" type="radio" value="23275">        </td>
        <td class="c1 text ">
          <label for="resp5456_23275">
            <span class="anun">e<span class="anumsep">.</span></span> Runtime exception            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer. <br><br>There is nothing wrong with the code, it will compile and run without any error and it will print - 57.0. <br><br>It is important to understand that the str.concat(".5") statement at line 2 *does not* modify the original String str, since String objects are immutable. Hence, the value of str is "19" even after the execution of line 6. <br><br>At line 3, Double d becomes 19.0 (note it is 19.0 and not 19.5 as str has not been altered). <br><br>At line 4, Long l also becomes 19. <br><br>The print statement at line 5 has the addition - <br><br>
<div style="margin-left: 40px;">d.intValue() + d.doubleValue() + l.doubleValue() <br></div><br>which is evaluated as: 19 + 19.0 + 19.0 And thus, this code prints 57.0.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%204%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5457" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                4      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following are true about the File class? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5457_23276" name="resp5457_23276" type="checkbox" value="23276">        </td>
        <td class="c1 text ">
          <label for="resp5457_23276">
            <span class="anun">a<span class="anumsep">.</span></span> You can perform file I/O operations using its methods.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5457_23277" name="resp5457_23277" checked="checked" type="checkbox" value="23277">        </td>
        <td class="c1 text ">
          <label for="resp5457_23277">
            <span class="anun">b<span class="anumsep">.</span></span> You can find the size of a file using its size() method.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5457_23278" name="resp5457_23278" checked="checked" type="checkbox" value="23278">        </td>
        <td class="c1 text correct">
          <label for="resp5457_23278">
            <span class="anun">c<span class="anumsep">.</span></span> You can check if a file exists using its exists() method.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5457_23279" name="resp5457_23279" type="checkbox" value="23279">        </td>
        <td class="c1 text correct">
          <label for="resp5457_23279">
            <span class="anun">d<span class="anumsep">.</span></span> You can delete a file using its delete() method.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices C and D are the correct answers.<br><br> The exists() method of the File class returns true if the file given by the abstract path name physically exists. <br><br>The delete() method can be used to delete the file represented by the File object. <br><br>Choice A is incorrect because we cannot perform read/write operations on files using the File object. <br><br>Choice B is incorrect because the File class does not define a size() method, it defines the length() method to find the size of a file. <br><br>Reference:<br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html">http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%205%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5458" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                5      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Consider the following code statement.<br>
 <br>
 Float f = new Float(3.14);<br>
 <br>
 Which of the calls listed below modify the object - f?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5458_23280" name="resp5458_" type="radio" value="23280">        </td>
        <td class="c1 text ">
          <label for="resp5458_23280">
            <span class="anun">a<span class="anumsep">.</span></span> f.parseFloat("2.718")            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5458_23281" name="resp5458_" type="radio" value="23281">        </td>
        <td class="c1 text ">
          <label for="resp5458_23281">
            <span class="anun">b<span class="anumsep">.</span></span> f.valueOf("3.1421")            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5458_23282" name="resp5458_" type="radio" value="23282">        </td>
        <td class="c1 text ">
          <label for="resp5458_23282">
            <span class="anun">c<span class="anumsep">.</span></span> f.byteValue()            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5458_23283" name="resp5458_" type="radio" value="23283">        </td>
        <td class="c1 text ">
          <label for="resp5458_23283">
            <span class="anun">d<span class="anumsep">.</span></span> f.setValue(Math.PI)            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5458_23284" name="resp5458_" checked="checked" type="radio" value="23284">        </td>
        <td class="c1 text correct">
          <label for="resp5458_23284">
            <span class="anun">e<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice E is the correct answer. <br>
 <br>
 All the wrapper classes are immutable, i.e. once created; their value can't be changed. <br>
 <br>
 The method setValue() does not exist. Other methods do return values but they do not modify the state of the object itself.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%206%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5459" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                6      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile and run the given code?<br><br> 1. public class EqualsTest<br> 2.{ <br>3. public static void main(String[] args)<br> 4.{<br> 5. Boolean b = new Boolean(true); <br>6. String str = new String(""+b); <br>7. StringBuffer buff = new StringBuffer(str); <br>8. <br>9. System.out.println(b.equals(str) + ", " + <br>10. str.equals(buff) + ", " + <br>11. buff.equals(b)); <br>12. }<br> 13. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5459_23285" name="resp5459_" type="radio" value="23285">        </td>
        <td class="c1 text ">
          <label for="resp5459_23285">
            <span class="anun">a<span class="anumsep">.</span></span> It will print - false, true, false            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5459_23286" name="resp5459_" type="radio" value="23286">        </td>
        <td class="c1 text ">
          <label for="resp5459_23286">
            <span class="anun">b<span class="anumsep">.</span></span> It will print - true, true, false            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5459_23287" name="resp5459_" checked="checked" type="radio" value="23287">        </td>
        <td class="c1 text correct">
          <label for="resp5459_23287">
            <span class="anun">c<span class="anumsep">.</span></span> It will print - false, false, false            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5459_23288" name="resp5459_" type="radio" value="23288">        </td>
        <td class="c1 text ">
          <label for="resp5459_23288">
            <span class="anun">d<span class="anumsep">.</span></span> It will print - true, false, false            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5459_23289" name="resp5459_" type="radio" value="23289">        </td>
        <td class="c1 text ">
          <label for="resp5459_23289">
            <span class="anun">e<span class="anumsep">.</span></span> Compilation error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5459_23290" name="resp5459_" type="radio" value="23290">        </td>
        <td class="c1 text ">
          <label for="resp5459_23290">
            <span class="anun">f<span class="anumsep">.</span></span> ClassCastException at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> The code will compile and run without any error and it will print - false, false, false. <br><br>Lines 5, 6 and 7 create object of Boolean, String and StringBuffer respectively. <br><br>At line 9, the call b.equals(str) evaluates to false. This is because the equals method overridden in class Boolean returns true if and only if the object passed to it is a non-null Boolean and represents the same boolean value as the Boolean object on which the equals() method is invoked. In this case, the passed object is a String (str) and hence this call yields false. <br><br>At line 10, the call str.equals(buff) is evaluated to false. This is because the equals method overridden in class String returns true if and only if the argument passed to it is not null and is a String object that represents the same sequence of characters as the String object on which the equals() method is invoked. In this case, the passed object is a StringBuffer (buff) and hence this call returns false. <br><br>At line 11, the call buff.equals(b) is evaluated to false, because StringBuffer *does not* override the equals method. The class StringBuffer inherits its equals() method from the parent class Object. The equals method implementation in Object class returns true if and only if the object passed to it also refers to the same object as the one on which the method has been invoked. In this case, obviously str and buff are two distinct objects, and hence this call returns false. <br><br>Thus the code prints - false, false, false. It is helpful to remember it this way -<br><br>
<div style="margin-left: 40px;"> &lt;WrapperClassObject&gt;.equals(any-other-class-object) =&gt; returns false. <br>&lt;String&gt;.equals(anything-else-except-String) =&gt; returns false <br>&lt;StringBuffer&gt;.equals(different-object-reference) =&gt; returns false <br></div><br>In case of StringBuffer even if two distinct objects are of type StringBuffer and they have same sequence of characters it will return false for equals() comparison. It will return true if and only if two references refer to the *same* object, not otherwise. <br><br>That is, the following will print false. <br><br>
<div style="margin-left: 40px;">StringBuffer buff1 = new StringBuffer("Java");<br> StringBuffer buff2 = new StringBuffer("Java"); <br>System.out.println(buff2.equals(buff1));<br></div><br> Also, note that passing objects of dissimilar classes as an argument to the equals() method does not result in compile time or runtime error.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%207%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5460" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                7      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the given code?<br><br> NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);<br><br> try <br>{<br>
<div style="margin-left: 40px;"> Number number = numberFormat.parse("4,455.67");<br> System.out.println(number.intValue()); <br></div>}<br><br> catch (java.text.ParseException ex) <br>{ <br>
<div style="margin-left: 40px;">System.out.println("Error");<br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5460_23291" name="resp5460_" type="radio" value="23291">        </td>
        <td class="c1 text ">
          <label for="resp5460_23291">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error :intValue method not defined in Number            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5460_23292" name="resp5460_" type="radio" value="23292">        </td>
        <td class="c1 text ">
          <label for="resp5460_23292">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "Error"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5460_23293" name="resp5460_" type="radio" value="23293">        </td>
        <td class="c1 text ">
          <label for="resp5460_23293">
            <span class="anun">c<span class="anumsep">.</span></span> Prints  4,455            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5460_23294" name="resp5460_" checked="checked" type="radio" value="23294">        </td>
        <td class="c1 text correct">
          <label for="resp5460_23294">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 4455            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5460_23295" name="resp5460_" type="radio" value="23295">        </td>
        <td class="c1 text ">
          <label for="resp5460_23295">
            <span class="anun">e<span class="anumsep">.</span></span> Prints 4455.67            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> NumberFormat helps you to format and parse numbers for any locale. <br><br>It parses text from the beginning of the given string to produce a number. The comma and similar formatting characters are removed from the text, so choice C is incorrect. <br><br>Since D is correct, the other choices are automatically incorrect. <br><br>The Number class defines the intValue() method which converts any wrapper type to its equivalent primitive int. So the decimal portion is lost and the output is 4455. <br><br>Reference: <br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html">http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%208%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5461" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                8      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of attempting to compile and run the given code? <br><br>import java.util.*; <br>import java.util.regex.*; <br><br>class ScannerTest2<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">String input = "10 apples 20 oranges 33 pears"; <br>Scanner s = new Scanner(input).useDelimiter("\\d*"); <br>String str[]=new String[6]; <br>int i=0; <br>while(s.hasNext()) <br>{ <br>
    <div style="margin-left: 40px;">str[i]=s.next(); <br>System.out.println(str[i++]); <br></div>} <br>s.close(); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5461_23296" name="resp5461_" type="radio" value="23296">        </td>
        <td class="c1 text ">
          <label for="resp5461_23296">
            <span class="anun">a<span class="anumsep">.</span></span> Prints "apples", "oranges", "pears" in separate lines.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5461_23297" name="resp5461_" type="radio" value="23297">        </td>
        <td class="c1 text ">
          <label for="resp5461_23297">
            <span class="anun">b<span class="anumsep">.</span></span> Prints  "10", "apples", "20", "oranges", "30", "pears" in separate lines.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5461_23298" name="resp5461_" type="radio" value="23298">        </td>
        <td class="c1 text correct">
          <label for="resp5461_23298">
            <span class="anun">c<span class="anumsep">.</span></span> Exception thrown at runtime.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5461_23299" name="resp5461_" type="radio" value="23299">        </td>
        <td class="c1 text ">
          <label for="resp5461_23299">
            <span class="anun">d<span class="anumsep">.</span></span> Code does not compile.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5461_23300" name="resp5461_" checked="checked" type="radio" value="23300">        </td>
        <td class="c1 text ">
          <label for="resp5461_23300">
            <span class="anun">e<span class="anumsep">.</span></span> None of these.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>The java.util.Scanner class makes it easier to read and parse strings and primitive types using regular expressions. You can change the delimiter that is used to tokenize the input, through the useDelimiter method of Scanner. You can pass in a String or a java.util.regex.Pattern to the method. You can read the input one line at a time by using the newline character (\n) as a delimiter. <br><br>The hasNext() method in Scanner returns true if another token exists in the Scanner's input, which is the case until it reaches the end of the file. <br><br>The next() method returns a String that represents the next token. The regular expression \\d will be required to match a digit. The '*' quantifier is used to match zero or more occurrences of it. There are zero digits between the letters in the String, so they are also considered matches for '*'. So it splits the String into "a", "p", "p" and so on, thus exceeding the bounds of the array str. Thus the result is ArrayIndexOutOfBoundsException being thrown at runtime. <br><br>References: <br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html</a> <br><a href="http://java.sun.com/developer/JDCTechTips/2004/tt1201.html">http://java.sun.com/developer/JDCTechTips/2004/tt1201.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%209%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5462" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                9      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the given code? <br><br>String input = "AA BB CC"; <br>Scanner s = new Scanner(input).useDelimiter("\s"); <br>while(s.hasNext()) <br>
<div style="margin-left: 40px;">System.out.print(s.next()+" "); <br></div> s.close();</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5462_23301" name="resp5462_" type="radio" value="23301">        </td>
        <td class="c1 text ">
          <label for="resp5462_23301">
            <span class="anun">a<span class="anumsep">.</span></span> Prints "AA BB CC"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5462_23302" name="resp5462_" type="radio" value="23302">        </td>
        <td class="c1 text ">
          <label for="resp5462_23302">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "AABBCC"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5462_23303" name="resp5462_" checked="checked" type="radio" value="23303">        </td>
        <td class="c1 text correct">
          <label for="resp5462_23303">
            <span class="anun">c<span class="anumsep">.</span></span> Does not compile            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5462_23304" name="resp5462_" type="radio" value="23304">        </td>
        <td class="c1 text ">
          <label for="resp5462_23304">
            <span class="anun">d<span class="anumsep">.</span></span> Causes an exception to be thrown            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>This code does not compile because "\s" is not recognized by the compiler as a legal escape sequence. The line causes the compiler error "Illegal escape character". <br><br>The code will compile if "\s" is replaced by \\s. Then the output would be "AA BB CC". <br><br>Since choice C is correct, all the other choices are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2010%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5463" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                10      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of compiling and running the following code? <br><br>class Test<br>{ <br> public static void main (String[] args) <br>{ <br> 1. StringBuffer s="hello"; <br>2. String s1=null; <br>3. s.append(s1); <br>4. System.out.println(s); <br>} <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5463_23305" name="resp5463_" type="radio" value="23305">        </td>
        <td class="c1 text ">
          <label for="resp5463_23305">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 3.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5463_23306" name="resp5463_" type="radio" value="23306">        </td>
        <td class="c1 text ">
          <label for="resp5463_23306">
            <span class="anun">b<span class="anumsep">.</span></span> NullPointerException thrown at runtime.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5463_23307" name="resp5463_" type="radio" value="23307">        </td>
        <td class="c1 text ">
          <label for="resp5463_23307">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "hellonull".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5463_23308" name="resp5463_" checked="checked" type="radio" value="23308">        </td>
        <td class="c1 text correct">
          <label for="resp5463_23308">
            <span class="anun">d<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br><br>A compilation error will occur at line 1 because you are trying to assign a String object to a StringBuffer object. This is not allowed because a String object is not in the object hierarchy of StringBuffer. There is no error at line 3. Thus, choice A is incorrect. <br><br>The append method in the StringBuffer is overloaded to take an argument of type Object, so any object can be passed to this method. So passing null will not cause any errors. <br><br>Since the code does not even compile, choices B and C are automatically incorrect. <br><br>Reference: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuffer.html">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuffer.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2011%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5464" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                11      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following methods are defined by the Serializable interface?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5464_23309" name="resp5464_" type="radio" value="23309">        </td>
        <td class="c1 text ">
          <label for="resp5464_23309">
            <span class="anun">a<span class="anumsep">.</span></span> readObject and writeObject            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5464_23310" name="resp5464_" type="radio" value="23310">        </td>
        <td class="c1 text ">
          <label for="resp5464_23310">
            <span class="anun">b<span class="anumsep">.</span></span> readExternal and writeExternal            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5464_23311" name="resp5464_" type="radio" value="23311">        </td>
        <td class="c1 text ">
          <label for="resp5464_23311">
            <span class="anun">c<span class="anumsep">.</span></span> serialize and deserialize            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5464_23312" name="resp5464_" checked="checked" type="radio" value="23312">        </td>
        <td class="c1 text correct">
          <label for="resp5464_23312">
            <span class="anun">d<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br>
 <br>
 An object is serializable only if its class implements the Serializable interface. Thus, if you want to serialize the instances of one of your classes, the class must implement the Serializable interface. <br>
 <br>
 However, it is interesting to note that Serializable is an empty interface. That is, it doesn't contain any method declarations; its purpose is simply to identify classes whose objects are serializable. So all the other choices are automatically incorrect.<br>
 <br>
 Reference:<br>
 <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2012%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16290" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                12      </div>
      </div>
  <div class="content">
    <div class="qtext">
  A block of text contains 10 words. You are required to make a list of distinct words from those 10 words. Choose the correct option that specifies the collection that can be used here.</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16290_61932" name="resp16290_" type="radio" value="61932">        </td>
        <td class="c1 text ">
          <label for="resp16290_61932">
            <span class="anun">a<span class="anumsep">.</span></span> ArrayList.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16290_61933" name="resp16290_" checked="checked" type="radio" value="61933">        </td>
        <td class="c1 text correct">
          <label for="resp16290_61933">
            <span class="anun">b<span class="anumsep">.</span></span> HashSet.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16290_61934" name="resp16290_" type="radio" value="61934">        </td>
        <td class="c1 text ">
          <label for="resp16290_61934">
            <span class="anun">c<span class="anumsep">.</span></span> LinkedList.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16290_61935" name="resp16290_" type="radio" value="61935">        </td>
        <td class="c1 text ">
          <label for="resp16290_61935">
            <span class="anun">d<span class="anumsep">.</span></span> HashMap.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : B <br><br>Explanation: <br>The string array can be thought of as a block of text containing 'n' words, and this small code extracts distinct words from it using the HashSet class and its size() method. <br><br>LinkedList and ArrayList are implementations of the List interface. As they do not reject duplicates, all the words would be added to the list (here, list means list in English, not in Java). <br><br>HashMap would be useful for mapping key-value pairs, such as words and their meaning. Hence, it is not a correct choice. <br><br>Reference: <br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashSet.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashSet.html </a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2013%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5465" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                13      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following can read the password from the console into passwd?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5465_23313" name="resp5465_" checked="checked" type="radio" value="23313">        </td>
        <td class="c1 text correct">
          <label for="resp5465_23313">
            <span class="anun">a<span class="anumsep">.</span></span> char[] passwd = System.console().readPassword("[%s]", "Password:");            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5465_23314" name="resp5465_" type="radio" value="23314">        </td>
        <td class="c1 text ">
          <label for="resp5465_23314">
            <span class="anun">b<span class="anumsep">.</span></span> String passwd = System.console().readPassword();            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5465_23315" name="resp5465_" type="radio" value="23315">        </td>
        <td class="c1 text ">
          <label for="resp5465_23315">
            <span class="anun">c<span class="anumsep">.</span></span> char passwd = System.console().readPassword();            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5465_23316" name="resp5465_" type="radio" value="23316">        </td>
        <td class="c1 text ">
          <label for="resp5465_23316">
            <span class="anun">d<span class="anumsep">.</span></span> String passwd;  <br>&nbsp;&nbsp;&nbsp;&nbsp;System.console().readPassword(str);            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is correct. <br><br>The readPassword() method in the Console class is used to read the password from the console. It has two overloaded forms. <br>
<ul>
  <li>public char[] readPassword(String fmt, Object... args) This form provides a formatted prompt, then reads a password or passphrase from the console with echoing disabled. <br></li>
  <li>public char[] readPassword() This form reads a password or passphrase from the console with echoing disabled. <br></li>
</ul>Both forms return the password in a char array; hence choice A is correct while all the other choices are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2014%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5468" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                14      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the given code?<br><br> import java.util.*;<br> public class Sorter<br>{<br>
<div style="margin-left: 40px;"> public static void main(String[] argv)<br>{<br>
  <div style="margin-left: 40px;"> ArrayList&lt;String&gt; aList = new ArrayList&lt;String&gt;();<br> aList.add("USA");<br> aList.add("Russia");<br> aList.add("UK");<br> int pos=Collections.binarySearch(aList,"Russia"); <br>System.out.println(pos);<br></div> }<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23325" name="resp5468_" type="radio" value="23325">        </td>
        <td class="c1 text ">
          <label for="resp5468_23325">
            <span class="anun">a<span class="anumsep">.</span></span> 0            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23326" name="resp5468_" type="radio" value="23326">        </td>
        <td class="c1 text ">
          <label for="resp5468_23326">
            <span class="anun">b<span class="anumsep">.</span></span> 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23327" name="resp5468_" type="radio" value="23327">        </td>
        <td class="c1 text ">
          <label for="resp5468_23327">
            <span class="anun">c<span class="anumsep">.</span></span> 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23328" name="resp5468_" type="radio" value="23328">        </td>
        <td class="c1 text ">
          <label for="resp5468_23328">
            <span class="anun">d<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23329" name="resp5468_" type="radio" value="23329">        </td>
        <td class="c1 text ">
          <label for="resp5468_23329">
            <span class="anun">e<span class="anumsep">.</span></span> Exception at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5468_23330" name="resp5468_" checked="checked" type="radio" value="23330">        </td>
        <td class="c1 text correct">
          <label for="resp5468_23330">
            <span class="anun">f<span class="anumsep">.</span></span> Compiles correctly, output is undefined            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice F is the correct answer.<br><br> The binarySearch method defined in the Collections class searches the specified list for the specified object using a binary search algorithm. <br><br>The list must be sorted into ascending order according to the natural ordering of its elements (as by the sort(List) method, above) prior to making this call. <br><br>If it is not sorted, the results are undefined. If the list contains multiple elements equal to the specified object, there is no guarantee which one will be found. Since the order cannot be decided, all the other choices are incorrect.<br><br.><br> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html</a></br.>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2015%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5469" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                15      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which is the most suitable Java collection class for storing various currencies and their equivalent prices in USD if multiple threads access and modify this data? It is required that the class should be synchronized inherently.</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5469_23331" name="resp5469_" type="radio" value="23331">        </td>
        <td class="c1 text ">
          <label for="resp5469_23331">
            <span class="anun">a<span class="anumsep">.</span></span> HashSet            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5469_23332" name="resp5469_" type="radio" value="23332">        </td>
        <td class="c1 text ">
          <label for="resp5469_23332">
            <span class="anun">b<span class="anumsep">.</span></span> Vector            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5469_23333" name="resp5469_" checked="checked" type="radio" value="23333">        </td>
        <td class="c1 text correct">
          <label for="resp5469_23333">
            <span class="anun">c<span class="anumsep">.</span></span> Hashtable            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5469_23334" name="resp5469_" type="radio" value="23334">        </td>
        <td class="c1 text ">
          <label for="resp5469_23334">
            <span class="anun">d<span class="anumsep">.</span></span> HashMap            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5469_23335" name="resp5469_" type="radio" value="23335">        </td>
        <td class="c1 text ">
          <label for="resp5469_23335">
            <span class="anun">e<span class="anumsep">.</span></span> TreeMap            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>The currencies and their equivalent values need to be stored in key-value pairs. The Map is the collection type which can store key-value pairs. Among all the Java collection classes implementing Map, Hashtable is the only class that is inherently thread-safe. Hence, Hashtable is the correct answer. <br><br>Choices A and B are incorrect because HashSet and Vector are not maps. Choices D and E are incorrect because even though these are Map types, HashMap and TreeMap are not synchronized. <br><br>Reference: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Hashtable.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Hashtable.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2016%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5470" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                16      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following declarations are valid? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5470_23336" name="resp5470_23336" checked="checked" type="checkbox" value="23336">        </td>
        <td class="c1 text correct">
          <label for="resp5470_23336">
            <span class="anun">a<span class="anumsep">.</span></span> List&lt;Object&gt; list;            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5470_23337" name="resp5470_23337" type="checkbox" value="23337">        </td>
        <td class="c1 text ">
          <label for="resp5470_23337">
            <span class="anun">b<span class="anumsep">.</span></span> Set&lt;int&gt; set;            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5470_23338" name="resp5470_23338" checked="checked" type="checkbox" value="23338">        </td>
        <td class="c1 text correct">
          <label for="resp5470_23338">
            <span class="anun">c<span class="anumsep">.</span></span> Map&lt;Number,Map&gt; map1;            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5470_23339" name="resp5470_23339" type="checkbox" value="23339">        </td>
        <td class="c1 text ">
          <label for="resp5470_23339">
            <span class="anun">d<span class="anumsep">.</span></span> Map&lt;String&gt; map2;            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5470_23340" name="resp5470_23340" checked="checked" type="checkbox" value="23340">        </td>
        <td class="c1 text correct">
          <label for="resp5470_23340">
            <span class="anun">e<span class="anumsep">.</span></span> Vector&lt;Map&gt; vect;            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, C and E are the correct choices.<br><br> Choice A is correct because it is legal to declare a List which can accept objects of Object type, though it is not really useful. <br><br>Choice B is incorrect because you cannot declare a collection that accepts primitives. <br><br>Choice C is correct because it is legal to have a Map which accepts keys of type Number and values which are Map objects themselves. <br><br>Choice D is incorrect because a Map cannot be declared with just one type, the types for both key and value need to be specified. <br><br>Choice E is correct because a Vector can be declared to accept Map objects alone. <br><br>Check out this comprehensive tutorial on generics to learn more: <a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf">http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2017%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5471" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                17      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the given code?<br><br> List&lt;? extends Object&gt; aList = new Vector&lt;String&gt;();<br> aList.add("USA");<br> aList.add("Russia");<br> aList.add("UK"); <br>for(String s : aList) <br>
<div style="margin-left: 40px;">System.out.print(s);</div></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5471_23341" name="resp5471_" checked="checked" type="radio" value="23341">        </td>
        <td class="c1 text ">
          <label for="resp5471_23341">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error: Incorrect syntax used for declaration of the generic type aList.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5471_23342" name="resp5471_" type="radio" value="23342">        </td>
        <td class="c1 text ">
          <label for="resp5471_23342">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error: Vector object cannot be assigned to a List type variable.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5471_23343" name="resp5471_" type="radio" value="23343">        </td>
        <td class="c1 text ">
          <label for="resp5471_23343">
            <span class="anun">c<span class="anumsep">.</span></span> Compiles correctly and prints "USAUKRussia".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5471_23344" name="resp5471_" type="radio" value="23344">        </td>
        <td class="c1 text ">
          <label for="resp5471_23344">
            <span class="anun">d<span class="anumsep">.</span></span> Compiles correctly and prints "USA", "UK" and "Russia" in an order which cannot be predicted.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5471_23345" name="resp5471_" type="radio" value="23345">        </td>
        <td class="c1 text correct">
          <label for="resp5471_23345">
            <span class="anun">e<span class="anumsep">.</span></span> None of these.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice E is the correct answer.<br><br> The add method causes compiler error. The wild card notation List&lt;? extends Object&gt; indicates a list which can accept any kind of Object. However, you cannot add or remove from such a collection since the actual type is unknown at compile time. <br><br>Choice A is incorrect because the syntax used for declaring aList is correct. <br><br>Choice B is incorrect because Vector is a subtype of List and hence can be assigned to it. <br><br>Choices C and D are incorrect because the code does not compile.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2018%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5472" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                18      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the given code? <br><br>Vector&lt;String&gt; aList=new Vector&lt;String&gt;(); // line 1 <br>aList.add("USA"); // line 2<br> aList.add("Russia"); // line 3 <br>aList.add("USA"); // line 4<br> aList.add("UK"); // line 5<br> List&lt;? extends Object&gt; l = aList; // line 6 <br>aList.sort(); // line 7<br> for(Object s : l) <br>
<div style="margin-left: 40px;">System.out.print(s);</div></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5472_23346" name="resp5472_" type="radio" value="23346">        </td>
        <td class="c1 text ">
          <label for="resp5472_23346">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error in line 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5472_23347" name="resp5472_" type="radio" value="23347">        </td>
        <td class="c1 text ">
          <label for="resp5472_23347">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error in line 4            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5472_23348" name="resp5472_" type="radio" value="23348">        </td>
        <td class="c1 text ">
          <label for="resp5472_23348">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error in line 6            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5472_23349" name="resp5472_" type="radio" value="23349">        </td>
        <td class="c1 text ">
          <label for="resp5472_23349">
            <span class="anun">d<span class="anumsep">.</span></span> Compiles correctly and prints "USARussiaUSAUK"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5472_23350" name="resp5472_" type="radio" value="23350">        </td>
        <td class="c1 text ">
          <label for="resp5472_23350">
            <span class="anun">e<span class="anumsep">.</span></span> Compiles correctly and prints "RussiaUKUSAUSA"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5472_23351" name="resp5472_" type="radio" value="23351">        </td>
        <td class="c1 text ">
          <label for="resp5472_23351">
            <span class="anun">f<span class="anumsep">.</span></span> Compiles correctly and prints "RussiaUKUSA"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5472_23352" name="resp5472_" checked="checked" type="radio" value="23352">        </td>
        <td class="c1 text correct">
          <label for="resp5472_23352">
            <span class="anun">g<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice G is the correct choice.<br><br> The code does not compile at line 7 because the Vector class does not define a sort() method. If line 7 is removed, the code compiles and runs fine printing "USARussiaUSAUK". <br><br>Choice A is incorrect because it is a legal way of instantiating the parameterized Vector type. <br><br>Choice B is also incorrect because there is no error in adding duplicate elements to a Vector. <br><br>Choice C is incorrect because it is a valid assignment. <br><br>Reference: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Vector.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Vector.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2019%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5473" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                19      </div>
      </div>
  <div class="content">
    <div class="qtext">
  A particular class has no data members to define its state, i.e. it has no instance variables; it only provides services through methods. How would you implement the equals() and hashCode() methods for this class?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5473_23353" name="resp5473_" checked="checked" type="radio" value="23353">        </td>
        <td class="c1 text ">
          <label for="resp5473_23353">
            <span class="anun">a<span class="anumsep">.</span></span> The hashCode() method will return a constant integer and equals() method will return true if another object is of same type.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5473_23354" name="resp5473_" type="radio" value="23354">        </td>
        <td class="c1 text ">
          <label for="resp5473_23354">
            <span class="anun">b<span class="anumsep">.</span></span> The hashCode() will return 0 and equals() will always return false.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5473_23355" name="resp5473_" type="radio" value="23355">        </td>
        <td class="c1 text ">
          <label for="resp5473_23355">
            <span class="anun">c<span class="anumsep">.</span></span> The hashCode() will return 1 and equals() will always return true.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5473_23356" name="resp5473_" type="radio" value="23356">        </td>
        <td class="c1 text correct">
          <label for="resp5473_23356">
            <span class="anun">d<span class="anumsep">.</span></span> It is not necessary to override the equals() and hashCode() methods for such a class.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        <p>Choice D is the correct answer. </p>
<p>Since the class has no instance variables, it is logically not required that it provides equals comparison with other objects. It will have no data that can be compared with other objects data to say that it is "equal" to another object. In this case, it is not necessary to provide any implementation for the equals() and hashCode() methods for this class. It will inherit these methods from the java.lang.Object class. </p>
<p>It is very important to understand "when" to override these methods; besides knowing "how" to override them. The primary purpose of the equals() method is to provide a comparison to see if an object of this class is logically equal to another object. For a class, which has no instance variables, this overriding is not necessary. </p>
<p>Moreover, in most cases where a class has no instance variables and provides only services through its methods, creating an instance of the class itself may not be required. One such example is the java.lang.Math class. </p>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2020%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5474" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                20      </div>
      </div>
  <div class="content">
    <div class="qtext">
  If an instance of a class needs to be added to a TreeSet, which interface this class must implement?<br>
 (Assume that the TreeSet is instantiated with the default no-argument constructor.)</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5474_23357" name="resp5474_" type="radio" value="23357">        </td>
        <td class="c1 text ">
          <label for="resp5474_23357">
            <span class="anun">a<span class="anumsep">.</span></span> java.util.SortedSet            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5474_23358" name="resp5474_" type="radio" value="23358">        </td>
        <td class="c1 text ">
          <label for="resp5474_23358">
            <span class="anun">b<span class="anumsep">.</span></span> java.lang.Cloneable            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5474_23359" name="resp5474_" checked="checked" type="radio" value="23359">        </td>
        <td class="c1 text correct">
          <label for="resp5474_23359">
            <span class="anun">c<span class="anumsep">.</span></span> java.lang.Comparable            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5474_23360" name="resp5474_" type="radio" value="23360">        </td>
        <td class="c1 text ">
          <label for="resp5474_23360">
            <span class="anun">d<span class="anumsep">.</span></span> java.util.RandomAccess            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5474_23361" name="resp5474_" type="radio" value="23361">        </td>
        <td class="c1 text ">
          <label for="resp5474_23361">
            <span class="anun">e<span class="anumsep">.</span></span> java.io.Serializable            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br>
 <br>
 A class that needs to be added to a TreeSet must implement the java.lang.Comparable interface, which imposes implementation of natural order. It is necessary that the class implements this interface so that a TreeSet can maintain its elements in a sorted order. <br>
 <br>
 This interface has only one method - public int compareTo(Object obj)<br>
 <br>
 This method compares this object with the specified object 'obj' for order. It returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. Moreover, it is strongly recommended (though not required) that natural orderings be consistent with equals. This is so because sorted sets (and sorted maps) without explicit comparators behave "strangely" when they are used with elements (or keys) whose natural ordering is inconsistent with equals. In particular, such a sorted set (or sorted map) violates the general contract for set (or map), which is defined in terms of the equals() method.<br>
 <br>
 The class TreeSet implements interface java.util.SortedSet, which specifies in its documentation -<br>
 <br>
 All elements inserted into a sorted set must implement the Comparable interface (or be accepted by the specified Comparator). Furthermore, all such elements must be mutually comparable: e1.compareTo(e2) (or comparator.compare(e1, e2)) must not throw a ClassCastException for any elements e1 and e2 in the sorted set. Attempts to violate this restriction will cause the offending method or constructor invocation to throw a ClassCastException.<br>
 <br>
 The assumption - TreeSet is instantiated with the default no-argument constructor states that no other Comparator is specified. Hence, a class that needs to be added to a TreeSet, must implement the java.lang.Comparable interface. <br>
 <br>
 It is not mandatory for that class to implement any other interface that has been listed in the choices above; hence all choices except C are incorrect.<br>
 <br>
 Reference:<br>
 <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/TreeSet.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/util/TreeSet.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2021%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5475" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                21      </div>
      </div>
  <div class="content">
    <div class="qtext">
  If the following code snippet prints: count = 3, which of the following statements are false? (Assume that the equals() and hashCode() methods have been overridden correctly.) <br><br>1. int count = 1; <br>2. if(a.equals(b)) <br>3. count++; <br>4. if(c.equals(d)) <br>5. count++; <br>6. if(a.hashCode() == b.hashCode()) <br>7. count++; <br>8. if(c.hashCode() == d.hashCode()) <br>9. count++; <br>10. System.out.println("count = " + count);</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5475_23362" name="resp5475_" type="radio" value="23362">        </td>
        <td class="c1 text ">
          <label for="resp5475_23362">
            <span class="anun">a<span class="anumsep">.</span></span> a.equals(b) and !(c.equals(d))            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5475_23363" name="resp5475_" type="radio" value="23363">        </td>
        <td class="c1 text ">
          <label for="resp5475_23363">
            <span class="anun">b<span class="anumsep">.</span></span> a.equals(b) or c.equals(d) but not both            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5475_23364" name="resp5475_" checked="checked" type="radio" value="23364">        </td>
        <td class="c1 text ">
          <label for="resp5475_23364">
            <span class="anun">c<span class="anumsep">.</span></span> a.hashCode()==b.hashCode() and c.hashCode() == d.hashCode()            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5475_23365" name="resp5475_" type="radio" value="23365">        </td>
        <td class="c1 text correct">
          <label for="resp5475_23365">
            <span class="anun">d<span class="anumsep">.</span></span> a.equals(b) and c.equals(d)            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> The statement in choice D is certainly false. The general contract of the hashCode() method says (From the API documentation) - If two objects are equal according to the equals(Object) method, then calling the hashCode() method on each of the two objects must produce the same integer result. <br><br>Thus, if a.equals(b) is true, a.hashCode() == b.hashCode() will also be true, hence the value of count will be incremented at line 3 and 7. This results in count = 3. However, if c.equals(d) is also true, then the value of count will be incremented at lines 3, 5, 7 and 9; which would make count = 5. Hence choice D is surely false and hence a correct choice.<br><br> Choice A is incorrect because if c.equals(d) is false, count would remain 3 if hashcodes are also different.<br><br> Choice B is incorrect because if only one of them is correct, then count=3 is a possibility.<br><br> Choice C is incorrect because the hashcodes of unequal objects can be equal. So a.hashCode()==b.hashCode() and c.hashCode() == d.hashCode() can be true even if a is not equal to b and c is not equal to d. In such a case also the count can be 3. <br>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2022%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5476" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                22      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile and run the following code?<br>
 <br>
 1.      public final class EqualsDemo<br>
 2.      {<br>
 3.              private String str;<br>
 4.              <br>
 5.              public EqualsDemo(String s)<br>
 6.              {<br>
 7.                      str = s;<br>
 8.              }<br>
 9.              <br>
 10.             public boolean equals(EqualsDemo obj)<br>
 11.             {<br>
 12.                     if(!(obj instanceof EqualsDemo))<br>
 13.                             return false;<br>
 14.                     EqualsDemo ed = (EqualsDemo)obj;<br>
 15.                     return (str == ed.str || (str != null &amp;&amp; str.equals(ed.str)));<br>
 16.             }<br>
 17.             <br>
 18.             public static void main(String[] args)<br>
 19.             {<br>
 20.                     EqualsDemo demo1 = new EqualsDemo("Java");<br>
 21.                     EqualsDemo demo2 = new EqualsDemo("java");<br>
 22.                     System.out.println(demo1.equals(demo2));<br>
 23.             }<br>
 24.     }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5476_23366" name="resp5476_" type="radio" value="23366">        </td>
        <td class="c1 text ">
          <label for="resp5476_23366">
            <span class="anun">a<span class="anumsep">.</span></span> It will print - true            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5476_23367" name="resp5476_" type="radio" value="23367">        </td>
        <td class="c1 text correct">
          <label for="resp5476_23367">
            <span class="anun">b<span class="anumsep">.</span></span> It will print - false            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5476_23368" name="resp5476_" checked="checked" type="radio" value="23368">        </td>
        <td class="c1 text ">
          <label for="resp5476_23368">
            <span class="anun">c<span class="anumsep">.</span></span> Compilation error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5476_23369" name="resp5476_" type="radio" value="23369">        </td>
        <td class="c1 text ">
          <label for="resp5476_23369">
            <span class="anun">d<span class="anumsep">.</span></span> Exception            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.<br>
 <br>
 There is nothing wrong with the code and it will compile and run without any error, printing the result "false". However, it is important to note that this code *does not* override the equals() method, instead it overloads the equals() method since the argument passed to the equals() method is of type "EqualsDemo" and not "java.lang.Object". It will not cause a compile time or runtime error due to this. Java does allow this type of overloading across classes.<br>
 <br>
 In this code, the objects of type EqualsDemo are created at lines 20 and 21 with strings "Java" and "java". The equals() method ensures that the argument passed is of type EqualsDemo and checks if String data of the argument is equal to the string data of this object. If they are not equal, false is returned. Since "Java" and "java" are not equal (note the case difference) this method returns false, which is printed at line 22.<br>
 <br>
 The concept that needs to be understood here is that passing an argument other than a java.lang.Object to the equals() method simply overloads the method instead of overriding it. This does not result in a compile time or runtime error. Hence, you should be careful that you do not overload the method unintentionally, instead of overriding it.<br>
 <br>
 Refer to <br>
 <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2023%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5477" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                23      </div>
      </div>
  <div class="content">
    <div class="qtext">
  How would you implement the hashCode() method correctly for the class shown below? (Assume that this class implements the equals() method correctly and choose the most appropriate implementation.) <br><br>public class HashDemo <br>{ <br>
<div style="margin-left: 40px;">private Integer arr[]; <br>//other methods not shown <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5477_23370" name="resp5477_" checked="checked" type="radio" value="23370">        </td>
        <td class="c1 text correct">
          <label for="resp5477_23370">
            <span class="anun">a<span class="anumsep">.</span></span> public int hashCode()  <br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7;          <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(arr == null) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(int i=0; i&lt;arr.length; i++) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash +(arr[i] == null? 0 : arr[i].hashCode()); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash;<br>&nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5477_23371" name="resp5477_" type="radio" value="23371">        </td>
        <td class="c1 text ">
          <label for="resp5477_23371">
            <span class="anun">b<span class="anumsep">.</span></span> public int hashCode()<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(arr == null)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(int i=0; i&lt;arr.length; i++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + arr[i].hashCode();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash;<br>&nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5477_23372" name="resp5477_" type="radio" value="23372">        </td>
        <td class="c1 text ">
          <label for="resp5477_23372">
            <span class="anun">c<span class="anumsep">.</span></span> public int hashCode()<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(arr == null)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + arr.hashCode();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash;<br>&nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5477_55818" name="resp5477_" type="radio" value="55818">        </td>
        <td class="c1 text ">
          <label for="resp5477_55818">
            <span class="anun">d<span class="anumsep">.</span></span> The array should not be involved in the calculation of the hashCode() method.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>All elements of an array should be involved in the hashCode computation. Likewise, they should also be involved in the equals comparison. This is a tough question and the key lies in understanding the fact that the elements of an array are the significant data members of the class and not the array variable itself. Hence all these elements should be involved in the implementation of the hashCode() method, or equals() method for that matter. <br><br>Choice B is incorrect because it does not check whether individual elements of an array are null or not. This implementation might result in a NullPointerException if any element of an array is null. <br><br>Choice C is obviously incorrect because it invokes the hashCode() method on the array reference instead of the array elements. <br><br>From all this discussion, it is clear that choice D does not make sense. Thus, only choice A takes care of all the array elements in the calculation of the hashCode and ensures that null values are taken care of. Hence, it is the correct answer. <br><br>Want to know more? Refer to: <br><a href="http://www.javaranch.com/newsletter/Oct2002/newsletteroct2002.jsp#%7Cequalandhash">http://www.javaranch.com/newsletter/Oct2002/newsletteroct2002.jsp#|equalandhash</a> <br><a href="http://developer.java.sun.com/developer/Books/effectivejava/Chapter3.pdf">http://developer.java.sun.com/developer/Books/effectivejava/Chapter3.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2024%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5478" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                24      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code?<br><br> Vector&lt;String&gt; aList=new Vector&lt;String&gt;(); // line 1 <br>aList.add("USA"); // line 2<br> aList.add("Russia"); // line 3 <br>aList.add("USA"); // line 4<br> aList.add(null); // line 5 <br>List&lt;? extends Object&gt; l = aList; // line 6<br> for(String s : l) // line 7<br>
<div style="margin-left: 40px;"> System.out.println(s);</div></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5478_23374" name="resp5478_" type="radio" value="23374">        </td>
        <td class="c1 text ">
          <label for="resp5478_23374">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error in line 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5478_23375" name="resp5478_" type="radio" value="23375">        </td>
        <td class="c1 text ">
          <label for="resp5478_23375">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error in line 4            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5478_23376" name="resp5478_" type="radio" value="23376">        </td>
        <td class="c1 text ">
          <label for="resp5478_23376">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error in line 5            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5478_23377" name="resp5478_" type="radio" value="23377">        </td>
        <td class="c1 text ">
          <label for="resp5478_23377">
            <span class="anun">d<span class="anumsep">.</span></span> Compiler error in line 6            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5478_23378" name="resp5478_" type="radio" value="23378">        </td>
        <td class="c1 text ">
          <label for="resp5478_23378">
            <span class="anun">e<span class="anumsep">.</span></span> Compiles correctly and prints "USARussiaUSAnull"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5478_23379" name="resp5478_" type="radio" value="23379">        </td>
        <td class="c1 text ">
          <label for="resp5478_23379">
            <span class="anun">f<span class="anumsep">.</span></span> Compiles correctly and prints "USARussianull"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5478_23380" name="resp5478_" checked="checked" type="radio" value="23380">        </td>
        <td class="c1 text correct">
          <label for="resp5478_23380">
            <span class="anun">g<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice G is the correct answer.<br><br> The code does not compile at line 7 because when you iterate through the list l, you get objects of type Object and they need to be cast down to String type. <br><br>Choice A is incorrect because line 1 uses the correct syntax. You can add duplicates to a Vector, there is nothing illegal in it. <br><br>Similarly adding null elements to the Vector is also allowed. So choices B and C are incorrect. <br><br>Choice D is incorrect because there is no error in the assignment. <br><br>Choices E and F are incorrect since the code does not even compile.<br><br> For more information, check out: <br><a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf">http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2025%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5479" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                25      </div>
      </div>
  <div class="content">
    <div class="qtext">
  There are 10 threads waiting for the lock of an object. How will you bring the 5th thread myThread out of the waiting state?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5479_23381" name="resp5479_" type="radio" value="23381">        </td>
        <td class="c1 text ">
          <label for="resp5479_23381">
            <span class="anun">a<span class="anumsep">.</span></span> By calling notify(5)            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5479_23382" name="resp5479_" type="radio" value="23382">        </td>
        <td class="c1 text correct">
          <label for="resp5479_23382">
            <span class="anun">b<span class="anumsep">.</span></span> By calling notifyAll()            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5479_23383" name="resp5479_" type="radio" value="23383">        </td>
        <td class="c1 text ">
          <label for="resp5479_23383">
            <span class="anun">c<span class="anumsep">.</span></span> By calling myThread.notify()            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5479_23384" name="resp5479_" type="radio" value="23384">        </td>
        <td class="c1 text ">
          <label for="resp5479_23384">
            <span class="anun">d<span class="anumsep">.</span></span> By calling notify(myThread)            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5479_23385" name="resp5479_" checked="checked" type="radio" value="23385">        </td>
        <td class="c1 text ">
          <label for="resp5479_23385">
            <span class="anun">e<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.  <br>
 <br>
 notify and notifyAll are instance (non static) methods of the Object class. The notify() method wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. It happens at the discretion of the thread scheduler and cannot be influenced. <br>
 <br>
 Choices A and D are incorrect because the notify method does not take any arguments. Choice C is incorrect because it is a method of the Object class and not of the Thread class. <br>
 <br>
 Choice B is correct because the notifyAll() method moves all the waiting threads into the runnable state. So all the 10 threads (including the 5th one) are notified when the notifyAll() method is invoked. <br>
 <br>
 Check out the API for more about the wait and notify methods: <br>
 <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2026%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5480" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                26      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements regarding threads is true?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5480_23386" name="resp5480_" type="radio" value="23386">        </td>
        <td class="c1 text ">
          <label for="resp5480_23386">
            <span class="anun">a<span class="anumsep">.</span></span> A thread dies as soon as the execution of the start() method ends.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5480_23387" name="resp5480_" checked="checked" type="radio" value="23387">        </td>
        <td class="c1 text ">
          <label for="resp5480_23387">
            <span class="anun">b<span class="anumsep">.</span></span> A thread's priority can be specified as an argument to its constructor.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5480_23388" name="resp5480_" type="radio" value="23388">        </td>
        <td class="c1 text ">
          <label for="resp5480_23388">
            <span class="anun">c<span class="anumsep">.</span></span> A sleeping thread can be made runnable by invoking notify().            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5480_23389" name="resp5480_" type="radio" value="23389">        </td>
        <td class="c1 text correct">
          <label for="resp5480_23389">
            <span class="anun">d<span class="anumsep">.</span></span> A thread can call notify() on an object only if it holds the lock on that object.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br>
 <br>
 A thread can call wait() or notify() on an object only if it holds that object's lock, else it causes an exception to be thrown. A thread dies only when the run() method ends. The call to the start() method returns immediately. So choice A is not correct. <br>
 <br>
 A thread's priority can be set using only the setPriority() method, there is no constructor which takes a priority argument. Thus choice B is false. <br>
 <br>
 A sleeping thread cannot be woken up by a call to notify(); notify() is called to bring a waiting thread out of the blocked state. So choice C is false and thus incorrect.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2027%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5481" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                27      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What can you write at the comment //A in the code below so that this program causes the word "running" to be printed to the standard output using a new thread of execution? <br><br>class RunTest implements Runnable <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">RunTest rt = new RunTest(); <br>Thread t = new Thread(rt); <br>//A <br></div>} <br>public void run() <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("running"); <br></div> } <br>void go() <br>{ <br>
  <div style="margin-left: 40px;">start(1); <br></div>} <br>void start(int i) { } <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5481_23390" name="resp5481_" type="radio" value="23390">        </td>
        <td class="c1 text ">
          <label for="resp5481_23390">
            <span class="anun">a<span class="anumsep">.</span></span> rt.run();            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5481_23391" name="resp5481_" type="radio" value="23391">        </td>
        <td class="c1 text ">
          <label for="resp5481_23391">
            <span class="anun">b<span class="anumsep">.</span></span> rt.start();            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5481_23392" name="resp5481_" type="radio" value="23392">        </td>
        <td class="c1 text ">
          <label for="resp5481_23392">
            <span class="anun">c<span class="anumsep">.</span></span> rt.go();            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5481_23393" name="resp5481_" type="radio" value="23393">        </td>
        <td class="c1 text ">
          <label for="resp5481_23393">
            <span class="anun">d<span class="anumsep">.</span></span> rt.start(1)            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5481_23394" name="resp5481_" checked="checked" type="radio" value="23394">        </td>
        <td class="c1 text correct">
          <label for="resp5481_23394">
            <span class="anun">e<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice E is the correct answer. <br><br>The new thread t will cause "running" to be printed, if its run method is called. To execute the run() method of RunTest in a separate thread, we need to call the start() method of the Thread and not of the Runnable object. So choice B is incorrect. <br><br>Choice A is incorrect because, though this causes the run() method to be called, it would not be using a new thread. Calling rt.start() will execute the start() method of RunTest, there is no such method defined in RunTest, and thus "running" won't be printed. <br><br>Calling rt.go() will execute the go() method of RunTest and thus won't print "running" either. So choices C and D are also incorrect. <br><br>Reference: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2028%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5482" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                28      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following? <br><br>class TestThread extends Thread <br>{ <br>
<div style="margin-left: 40px;">static String s=new String("hi"); <br>public void run() <br>{ <br>
  <div style="margin-left: 40px;">try <br>{ <br>
    <div style="margin-left: 40px;">synchronized(s) <br>{ <br></div>
    <div style="margin-left: 80px;">System.out.println(Thread.currentThread().getName()); <br>Thread.sleep(1000); <br>System.out.println(Thread.currentThread().getName()); <br></div>
    <div style="margin-left: 40px;">} <br></div>} <br>catch(InterruptedException e) {} <br></div>} <br><br>public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">TestThread t1 = new TestThread("A"); <br>TestThread t2 = new TestThread("B"); <br>t1.start(); <br>t2.start(); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5482_23395" name="resp5482_" type="radio" value="23395">        </td>
        <td class="c1 text correct">
          <label for="resp5482_23395">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5482_23396" name="resp5482_" type="radio" value="23396">        </td>
        <td class="c1 text ">
          <label for="resp5482_23396">
            <span class="anun">b<span class="anumsep">.</span></span> Exception at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5482_23397" name="resp5482_" checked="checked" type="radio" value="23397">        </td>
        <td class="c1 text ">
          <label for="resp5482_23397">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "AABB" or "BBAA"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5482_23398" name="resp5482_" type="radio" value="23398">        </td>
        <td class="c1 text ">
          <label for="resp5482_23398">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "ABAB" or "BABA"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5482_23399" name="resp5482_" type="radio" value="23399">        </td>
        <td class="c1 text ">
          <label for="resp5482_23399">
            <span class="anun">e<span class="anumsep">.</span></span> None of the above            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>This code does not compile because there is no matching constructor in the TestThread class which takes a String argument. <br><br>The Thread class does have a constructor which takes a String argument, but constructors are never inherited. So the compiler complains that it can't find a matching constructor. <br><br>This is a tricky question. It looks like it is testing your knowledge on synchronization, but the actual error is somewhere else. <br><br>Since the code does not compile, all the other choices are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2029%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5483" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                29      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile and run the following code? <br><br>1. public class ThreadTest implements Runnable <br>2. { <br>3. private int x; <br>4. <br>5. public int getData() <br>6. { <br>7. synchronized(x) <br>8. { <br>9. x = 123; <br>10. x = x + 12 ; <br>11. } <br>12. return x; <br>13. } <br>14. <br>15. public void run() <br>16. { <br>17. System.out.print(getData() + " "); <br>18. } <br>19. <br>20. public static void main(String[] args) <br>21. { <br>22. ThreadTest test = new ThreadTest(); <br>23. Thread th1 = new Thread(test); <br>24. Thread th2 = new Thread(test); <br>25. th1.start(); <br>26. th2.start(); <br>27. } <br>28. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5483_23400" name="resp5483_" type="radio" value="23400">        </td>
        <td class="c1 text ">
          <label for="resp5483_23400">
            <span class="anun">a<span class="anumsep">.</span></span> It will print: 135 135.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5483_23401" name="resp5483_" type="radio" value="23401">        </td>
        <td class="c1 text ">
          <label for="resp5483_23401">
            <span class="anun">b<span class="anumsep">.</span></span> It will print: 123 135.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5483_23402" name="resp5483_" type="radio" value="23402">        </td>
        <td class="c1 text ">
          <label for="resp5483_23402">
            <span class="anun">c<span class="anumsep">.</span></span> It will print: 135 123.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5483_23403" name="resp5483_" type="radio" value="23403">        </td>
        <td class="c1 text ">
          <label for="resp5483_23403">
            <span class="anun">d<span class="anumsep">.</span></span> It will print the values 123 and 135 but sequence can not be guaranteed.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5483_23404" name="resp5483_" checked="checked" type="radio" value="23404">        </td>
        <td class="c1 text correct">
          <label for="resp5483_23404">
            <span class="anun">e<span class="anumsep">.</span></span> The code will not compile.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice E is the correct answer. <br><br>The given code will not compile. It is important to understand that when synchronization is required for a particular block of code rather than a method, the lock is obtained on a particular object. <br><br>In this code, the variable 'x ' is a primitive integer and not an object so using it for synchronization will result in a compilation error. The code at line 7 causes compilation error. <br><br>Synchronization, and the usage of the keyword "synchronized" for a block of code is an important concept in multithreading. It is essential to understand the syntax, semantics and usage of synchronization.<br><br> In this question, the key lies in understanding the fact that a lock is obtained on an object, and not a primitive. <br><br>Want to know more? The following article discusses important concepts about multithreading - <a href="http://www.developerlife.com/lessons/threadsintro/default.htm">http://www.developerlife.com/lessons/threadsintro/default.htm</a> <br>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2030%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5484" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                30      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Given the following code, which of the given statements are true for an instance of the Vertical class ? Select two choices.<br><br> public class Vertical <br>{<br>
<div style="margin-left: 40px;"> private int alt;<br><br>public synchronized void up()<br> { <br>
  <div style="margin-left: 40px;">++alt; <br></div>} <br><br>public void down()<br> { <br>
  <div style="margin-left: 40px;">--alt; <br></div>}<br><br>public synchronized void jump() <br>{ <br></div>
<div style="margin-left: 80px;">int a = alt; <br>up();<br> down(); <br>assert(a == alt); <br></div>
<div style="margin-left: 40px;">} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5484_23405" name="resp5484_23405" type="checkbox" value="23405">        </td>
        <td class="c1 text ">
          <label for="resp5484_23405">
            <span class="anun">a<span class="anumsep">.</span></span> Code does not compile.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5484_23406" name="resp5484_23406" type="checkbox" value="23406">        </td>
        <td class="c1 text ">
          <label for="resp5484_23406">
            <span class="anun">b<span class="anumsep">.</span></span> Code will compile only if the assert statement is removed.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5484_23407" name="resp5484_23407" type="checkbox" value="23407">        </td>
        <td class="c1 text ">
          <label for="resp5484_23407">
            <span class="anun">c<span class="anumsep">.</span></span> AssertionError will never be thrown by this code.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5484_23408" name="resp5484_23408" checked="checked" type="checkbox" value="23408">        </td>
        <td class="c1 text correct">
          <label for="resp5484_23408">
            <span class="anun">d<span class="anumsep">.</span></span> AssertionError may or may not be thrown by this code.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5484_23409" name="resp5484_23409" checked="checked" type="checkbox" value="23409">        </td>
        <td class="c1 text ">
          <label for="resp5484_23409">
            <span class="anun">e<span class="anumsep">.</span></span> Multiple threads may execute the up() method simultaneously.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5484_23410" name="resp5484_23410" type="checkbox" value="23410">        </td>
        <td class="c1 text correct">
          <label for="resp5484_23410">
            <span class="anun">f<span class="anumsep">.</span></span> Multiple threads may execute the down() method simultaneously.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices D and F are the correct answers.<br><br> In the given code, the up() method is synchronized, while the down() method is not. So the up() method cannot be executed by multiple threads at the same time, since only one thread can access the lock at a time. <br><br>However the down() method may be executed by many threads at the same time. So choice E is incorrect and choice F is correct. <br><br>Since the value of alt may be acted upon by more than one thread, the result of the expression (a==alt) cannot be predicted. AssertionError will be thrown if (a==alt) evaluates to false. So choice C is incorrect, while choice D is correct. <br><br>Choices A and B are incorrect since there are no compiler errors in this code.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2031%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16291" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                31      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Choose the statements which are true.<br>(Choose three options)<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16291_61936" name="resp16291_61936" checked="checked" type="checkbox" value="61936">        </td>
        <td class="c1 text correct">
          <label for="resp16291_61936">
            <span class="anun">a<span class="anumsep">.</span></span> Can not be serialized  : transient.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16291_61937" name="resp16291_61937" checked="checked" type="checkbox" value="61937">        </td>
        <td class="c1 text correct">
          <label for="resp16291_61937">
            <span class="anun">b<span class="anumsep">.</span></span> Shared by all instances of a class  : static.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16291_61938" name="resp16291_61938" type="checkbox" value="61938">        </td>
        <td class="c1 text ">
          <label for="resp16291_61938">
            <span class="anun">c<span class="anumsep">.</span></span> Cannot be inherited  : abstract.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16291_61939" name="resp16291_61939" checked="checked" type="checkbox" value="61939">        </td>
        <td class="c1 text correct">
          <label for="resp16291_61939">
            <span class="anun">d<span class="anumsep">.</span></span> Value cannot be changed : final.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : A,B,D <br><br>Explanation: <br>Static variable are defined at the class level,so they are shared by all the instances of the class. <br><br>If a variable is declared final its value, once assigned, cannot be changed. <br><br>Private variable are only accessible within the declaring class, they cannot be inherited by the subclass. <br><br>When an object is serialized, we can prevent any of its fields from being saved by declaring it as transient .      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2032%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5486" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                32      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the given options are legal return types for the method callMe() in the class Test? Select two choices.<br><br> interface X{}<br> class AA{} <br>class A extends AA implements X {} <br>class B extends A{}<br> class C extends B{} <br>class SuperTest<br>{<br>
<div style="margin-left: 40px;"> public A callMe()<br>{<br>
  <div style="margin-left: 40px;"> return new A();<br></div> }<br></div> }<br><br> public class Test extends SuperTest <br>{<br>
<div style="margin-left: 40px;"> public ??? callMe()<br>{<br>
  <div style="margin-left: 40px;"> return new C();<br></div> }<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5486_23417" name="resp5486_23417" type="checkbox" value="23417">        </td>
        <td class="c1 text ">
          <label for="resp5486_23417">
            <span class="anun">a<span class="anumsep">.</span></span> X            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5486_23418" name="resp5486_23418" type="checkbox" value="23418">        </td>
        <td class="c1 text ">
          <label for="resp5486_23418">
            <span class="anun">b<span class="anumsep">.</span></span> AA            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5486_23419" name="resp5486_23419" checked="checked" type="checkbox" value="23419">        </td>
        <td class="c1 text correct">
          <label for="resp5486_23419">
            <span class="anun">c<span class="anumsep">.</span></span> B            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5486_23420" name="resp5486_23420" checked="checked" type="checkbox" value="23420">        </td>
        <td class="c1 text correct">
          <label for="resp5486_23420">
            <span class="anun">d<span class="anumsep">.</span></span> C            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices C and D are the correct answers.<br><br> Support for covariant return types will allow a method overriding a super class method to return any subtype of the super class method's return type. So choices C and D are correct. <br><br>The return type declared in case of choices A and B is a supertype of the super class method's return type, which is not allowed. Thus, choices A and B are incorrect. <br><br>To know more about the covariant return types feature, refer to: <br><a href="http://java.sun.com/developer/JDCTechTips/2004/tt1201.html">http://java.sun.com/developer/JDCTechTips/2004/tt1201.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2033%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5487" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                33      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which is the correct method for getting the value of a String property 'name' according to the JavaBean naming standards?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5487_23421" name="resp5487_" type="radio" value="23421">        </td>
        <td class="c1 text ">
          <label for="resp5487_23421">
            <span class="anun">a<span class="anumsep">.</span></span> public String getname(){}            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5487_23422" name="resp5487_" type="radio" value="23422">        </td>
        <td class="c1 text ">
          <label for="resp5487_23422">
            <span class="anun">b<span class="anumsep">.</span></span> public String getName(String name){}            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5487_23423" name="resp5487_" checked="checked" type="radio" value="23423">        </td>
        <td class="c1 text correct">
          <label for="resp5487_23423">
            <span class="anun">c<span class="anumsep">.</span></span> public String getName(){}            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5487_23424" name="resp5487_" type="radio" value="23424">        </td>
        <td class="c1 text ">
          <label for="resp5487_23424">
            <span class="anun">d<span class="anumsep">.</span></span> public String get_name(){}            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>According to the JavaBean naming standards, if the property name is 'x' and the type is Type, the accessor method is of the form <br><br>
<div style="margin-left: 40px;">Type getX() <br></div><br>and the mutator method is of the form <br><br>
<div style="margin-left: 40px;">void setX(Type newValue) <br></div><br>Choice A is incorrect because the name of the method must be getName and not getname, the first letter of the property name is capitalized. <br><br>Choice B is incorrect because the getter method does not take any arguments. <br><br>Choice D is incorrect because the method name cannot contain an underscore. <br><br>You can download the JavaBean specification from: <a href="http://java.sun.com/products/javabeans/docs/index.html">http://java.sun.com/products/javabeans/docs/index.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2034%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5488" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                34      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the value of y when the following code is executed? <br><br>class A <br>{ <br>
<div style="margin-left: 40px;">int increment(int x) <br>{ <br>
  <div style="margin-left: 40px;">return x + 10; <br></div>} <br>long increment(int x) <br>{ <br>
  <div style="margin-left: 40px;">return x + 20; <br></div>} <br></div>} <br><br>class B extends A <br>{ <br>
<div style="margin-left: 40px;">static public void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">B b = new B(); <br>int y = b.increment(12); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5488_23425" name="resp5488_" type="radio" value="23425">        </td>
        <td class="c1 text ">
          <label for="resp5488_23425">
            <span class="anun">a<span class="anumsep">.</span></span> 12            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5488_23426" name="resp5488_" type="radio" value="23426">        </td>
        <td class="c1 text ">
          <label for="resp5488_23426">
            <span class="anun">b<span class="anumsep">.</span></span> 22            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5488_23427" name="resp5488_" type="radio" value="23427">        </td>
        <td class="c1 text ">
          <label for="resp5488_23427">
            <span class="anun">c<span class="anumsep">.</span></span> 32            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5488_23428" name="resp5488_" checked="checked" type="radio" value="23428">        </td>
        <td class="c1 text correct">
          <label for="resp5488_23428">
            <span class="anun">d<span class="anumsep">.</span></span> This code causes compile-time error.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br><br>Here two methods are declared with same name and same type(int) of input argument, which is not allowed. Hence the code will not compile. <br><br>Different return type is not a sufficient condition for methods to be overloaded. For a method to be overloaded, the number, type or order of arguments must be different. <br><br>More about overloading is available at: <a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#%7C8.4.9">http://java.sun.com/docs/books/jls/third_edition/html/classes.html#|8.4.9</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2035%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5489" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                35      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>public class EnumTest3<br>{ <br>
<div style="margin-left: 40px;">enum Employee<br>{ <br>
  <div style="margin-left: 40px;">MANAGER, CLERK, SECRETARY <br></div>} <br>public static void main(String[] argv)<br>{ <br>
  <div style="margin-left: 40px;">new EnumTest3(Employee.CLERK); <br></div>} <br>EnumTest3(Employee emp)<br>{ <br>
  <div style="margin-left: 40px;">switch (emp)<br>{ <br>
    <div style="margin-left: 40px;">case MANAGER: System.out.println("Manager"); <br>case CLERK: System.out.println("Clerk"); <br>case SECRETARY: System.out.println("Secretary"); <br></div>} <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5489_23429" name="resp5489_" type="radio" value="23429">        </td>
        <td class="c1 text ">
          <label for="resp5489_23429">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error : case statements must use enum name as prefix for constants.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5489_23430" name="resp5489_" type="radio" value="23430">        </td>
        <td class="c1 text ">
          <label for="resp5489_23430">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error : missing semicolon in enum syntax.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5489_23431" name="resp5489_" checked="checked" type="radio" value="23431">        </td>
        <td class="c1 text correct">
          <label for="resp5489_23431">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "Clerk" followed by "Secretary".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5489_23432" name="resp5489_" type="radio" value="23432">        </td>
        <td class="c1 text ">
          <label for="resp5489_23432">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "Clerk".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>Enumerated types are declared using the enum keyword. Here Employee is an enumeration type and MANAGER, CLERK and SECRETARY are values for that type. The switch statement now supports the use of enum values. <br><br>Since there are no break statements, the execution proceeds even after the matching case clause is encountered. So both "Clerk" and "Secretary" are printed. Thus choice C is correct and choice D is incorrect. <br><br>You must not preface each enumerated type with the enum class name, in the case statement. So choice A is incorrect. There are no errors in the enum syntax, so choice B is also incorrect. <br><br>Want to know more about enums? Refer to:<br><a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#%7C8.9">http://java.sun.com/docs/books/jls/third_edition/html/classes.html#|8.9</a> <br><a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html">http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2036%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5490" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                36      </div>
      </div>
  <div class="content">
    <div class="qtext">
  In the given piece of code, which members of class A can be accessed within class B? Select two choices.<br><br> package pack1;<br><br> public class A<br>{<br>
<div style="margin-left: 40px;"> int i; <br>public static float f;<br> static int j;<br> public void f(){}<br> public static void g(){} <br></div>} <br><br>package pack2;<br> import static pack1.A.*; <br>public class B<br>{ <br>
<div style="margin-left: 40px;">// Accessing A's members <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5490_23433" name="resp5490_23433" type="checkbox" value="23433">        </td>
        <td class="c1 text ">
          <label for="resp5490_23433">
            <span class="anun">a<span class="anumsep">.</span></span> i            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5490_23434" name="resp5490_23434" checked="checked" type="checkbox" value="23434">        </td>
        <td class="c1 text correct">
          <label for="resp5490_23434">
            <span class="anun">b<span class="anumsep">.</span></span> f            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5490_23435" name="resp5490_23435" type="checkbox" value="23435">        </td>
        <td class="c1 text ">
          <label for="resp5490_23435">
            <span class="anun">c<span class="anumsep">.</span></span> j            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5490_23436" name="resp5490_23436" type="checkbox" value="23436">        </td>
        <td class="c1 text ">
          <label for="resp5490_23436">
            <span class="anun">d<span class="anumsep">.</span></span> f()            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5490_23437" name="resp5490_23437" checked="checked" type="checkbox" value="23437">        </td>
        <td class="c1 text correct">
          <label for="resp5490_23437">
            <span class="anun">e<span class="anumsep">.</span></span> g()            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B and E are the correct answers.<br><br> For the members of a class to be visible in packages other than the one in which it is defined, the members must be defined public. So choices A and C are incorrect. <br><br>Class B is doing a static import, which means only static members of A would be imported. <br><br>So choices B and E are correct, while choice D is incorrect. <br><br>To know more, refer to:<br><a href="http://java.sun.com/docs/books/jls/third_edition/html/packages.html">http://java.sun.com/docs/books/jls/third_edition/html/packages.html </a><br> <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html">http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2037%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5491" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                37      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the given code? <br><br>class A<br>{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int b=10;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private A()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.b=7; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int f()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return b; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>} <br>class B extends A{ int b; } <br>class Test<br>{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String[] args)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A a=new B();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(a.f()); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5491_23438" name="resp5491_" type="radio" value="23438">        </td>
        <td class="c1 text correct">
          <label for="resp5491_23438">
            <span class="anun">a<span class="anumsep">.</span></span> Does not compile            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5491_23439" name="resp5491_" type="radio" value="23439">        </td>
        <td class="c1 text ">
          <label for="resp5491_23439">
            <span class="anun">b<span class="anumsep">.</span></span> Prints 0            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5491_23440" name="resp5491_" type="radio" value="23440">        </td>
        <td class="c1 text ">
          <label for="resp5491_23440">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 10            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5491_23441" name="resp5491_" checked="checked" type="radio" value="23441">        </td>
        <td class="c1 text ">
          <label for="resp5491_23441">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 7            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>The code does not compile because the constructor of class A is declared as private. This creates a problem when the subclass constructor makes an implicit super() call to the parent class constructor at the time B is instantiated. <br><br>Since the code does not compile, all the other choices are incorrect. If the constructor of A had not been private, the output would have been 7.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2038%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5493" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                38      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of compiling the following program? <br><br>interface myInter <br>{ <br>
<div style="margin-left: 40px;">abstract void f1(); // line 1 <br>protected int f2(); // line 2 <br>static double f3(); // line 3 <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5493_23446" name="resp5493_" type="radio" value="23446">        </td>
        <td class="c1 text ">
          <label for="resp5493_23446">
            <span class="anun">a<span class="anumsep">.</span></span> The code will compile correctly.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5493_23447" name="resp5493_" type="radio" value="23447">        </td>
        <td class="c1 text ">
          <label for="resp5493_23447">
            <span class="anun">b<span class="anumsep">.</span></span> The code will compile correctly if line 1 is removed.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5493_23448" name="resp5493_" checked="checked" type="radio" value="23448">        </td>
        <td class="c1 text ">
          <label for="resp5493_23448">
            <span class="anun">c<span class="anumsep">.</span></span> The code will compile correctly if line 2 is removed.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5493_23449" name="resp5493_" type="radio" value="23449">        </td>
        <td class="c1 text ">
          <label for="resp5493_23449">
            <span class="anun">d<span class="anumsep">.</span></span> The code will compile correctly if line 3 is removed.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5493_23450" name="resp5493_" type="radio" value="23450">        </td>
        <td class="c1 text correct">
          <label for="resp5493_23450">
            <span class="anun">e<span class="anumsep">.</span></span> The code will compile correctly if lines 2 and 3 are removed.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5493_23451" name="resp5493_" type="radio" value="23451">        </td>
        <td class="c1 text ">
          <label for="resp5493_23451">
            <span class="anun">f<span class="anumsep">.</span></span> The code will compile correctly if lines 1 and 3 are removed.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice E is the correct answer. <br><br>The given code will compile only if lines 2 and 3 are removed. <br><br>Line 2 gives compiler error because interface methods are implicitly public and cannot be declared as protected. <br><br>Line 3 gives error because interface methods cannot be declared static. There is no error in line 1 because interface methods are implicitly abstract and hence may be declared so. <br><br>Want to know more about interfaces? Check out: <a href="http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html">http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2039%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5494" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                39      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile and run the following code? <br><br>public final class Test <br>{ <br>
<div style="margin-left: 40px;">class Inner <br>{ <br>
  <div style="margin-left: 40px;">void test() <br>{ <br>
    <div style="margin-left: 40px;">if (Test.this.bool); <br>{ <br>
      <div style="margin-left: 40px;">myMethod(); <br></div>} <br></div></div></div>
<div style="margin-left: 80px;">} <br></div>
<div style="margin-left: 40px;">} <br></div>
<div style="margin-left: 40px;">private boolean bool = false; <br>public void myMethod() <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("myMethod"); <br></div>} <br>public Test() <br>{ <br>
  <div style="margin-left: 40px;">(new Inner()).test(); <br></div>} <br>public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">new Test(); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5494_23452" name="resp5494_" type="radio" value="23452">        </td>
        <td class="c1 text correct">
          <label for="resp5494_23452">
            <span class="anun">a<span class="anumsep">.</span></span> Prints "myMethod".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5494_23453" name="resp5494_" type="radio" value="23453">        </td>
        <td class="c1 text ">
          <label for="resp5494_23453">
            <span class="anun">b<span class="anumsep">.</span></span> Program produces no output but terminates correctly.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5494_23454" name="resp5494_" type="radio" value="23454">        </td>
        <td class="c1 text ">
          <label for="resp5494_23454">
            <span class="anun">c<span class="anumsep">.</span></span> Program does not terminate.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5494_23455" name="resp5494_" checked="checked" type="radio" value="23455">        </td>
        <td class="c1 text ">
          <label for="resp5494_23455">
            <span class="anun">d<span class="anumsep">.</span></span> The program will not compile.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> From the main() method, the constructor Test is invoked. <br><br>Inside the constructor, the class Inner is properly constructed and the test() method is called. Here comes the point to be noticed. After the if statementthere is a semicolon ';'. <br><br>Thus even if the Test.this.bool returns false, myMethod() will be invoked and thus "myMethod" will be printed.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2040%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5495" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                40      </div>
      </div>
  <div class="content">
    <div class="qtext">
  class ABC<br>{<br>
<div style="margin-left: 40px;"> static int[] arr1;<br> int[] arr2=new int[10]; <br>static float[] arr3={}; <br>void f()<br>{ <br></div>
<div style="margin-left: 80px;">double[] arr4; <br></div>
<div style="margin-left: 40px;">}<br></div> } <br><br>Which of the following are true about the above code? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5495_23456" name="resp5495_23456" checked="checked" type="checkbox" value="23456">        </td>
        <td class="c1 text correct">
          <label for="resp5495_23456">
            <span class="anun">a<span class="anumsep">.</span></span> arr1 is initialized to null            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5495_23457" name="resp5495_23457" checked="checked" type="checkbox" value="23457">        </td>
        <td class="c1 text ">
          <label for="resp5495_23457">
            <span class="anun">b<span class="anumsep">.</span></span> arr4 is initialized to null            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5495_23458" name="resp5495_23458" checked="checked" type="checkbox" value="23458">        </td>
        <td class="c1 text correct">
          <label for="resp5495_23458">
            <span class="anun">c<span class="anumsep">.</span></span> arr3.length==0            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5495_23459" name="resp5495_23459" type="checkbox" value="23459">        </td>
        <td class="c1 text ">
          <label for="resp5495_23459">
            <span class="anun">d<span class="anumsep">.</span></span> arr2.length==9            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5495_23460" name="resp5495_23460" type="checkbox" value="23460">        </td>
        <td class="c1 text correct">
          <label for="resp5495_23460">
            <span class="anun">e<span class="anumsep">.</span></span> arr2[0]==0            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, C and E are the correct answers.<br><br> Arrays declared as instance or static variables are initialized to null if they have not been explicitly initialized. So choice A is correct. <br><br>arr3 is initialized to an empty array, which means its length is 0, that is why choice C is also correct. <br><br>Since arr2 is initialized to an array of 10 elements, the length is 10 and not 9. This makes choice D incorrect. <br><br>Choice E is correct because each element is initialized to the default value for int, which is 0. <br><br>arr4 is not initialized to null since local variables are not implicitly initialized. So choice B is incorrect. <br><br>More about arrays is available at: <br><a href="http://java.sun.com/docs/books/jls/third_edition/html/arrays.html">http://java.sun.com/docs/books/jls/third_edition/html/arrays.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2041%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16292" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                41      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output of the following code. <br><br>class Demo <br>{ <br>
<div style="margin-left: 40px;"> public static void main(String [] args) <br></div>
<div style="margin-left: 40px;">{ <br></div>
<div style="margin-left: 80px;"> int j=0; <br> try <br>{ <br></div>
<div style="margin-left: 120px;">int i=1; <br>j=--i; <br>j/=i; <br></div>
<div style="margin-left: 80px;">} <br></div>
<div style="margin-left: 80px;">catch(RuntimeException e) <br></div>
<div style="margin-left: 80px;"> { <br></div>
<div style="margin-left: 120px;">System.out.println (++j); <br></div>
<div style="margin-left: 80px;">} <br></div>
<div style="margin-left: 80px;">finally <br></div>
<div style="margin-left: 80px;">{ <br></div>
<div style="margin-left: 120px;">System.out.println (j++); <br></div>
<div style="margin-left: 80px;">} <br></div>
<div style="margin-left: 80px;"> System.out.println(j); <br></div>
<div style="margin-left: 40px;">} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16292_61940" name="resp16292_" checked="checked" type="radio" value="61940">        </td>
        <td class="c1 text correct">
          <label for="resp16292_61940">
            <span class="anun">a<span class="anumsep">.</span></span> 112.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16292_61941" name="resp16292_" type="radio" value="61941">        </td>
        <td class="c1 text ">
          <label for="resp16292_61941">
            <span class="anun">b<span class="anumsep">.</span></span> Compilation error.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16292_61942" name="resp16292_" type="radio" value="61942">        </td>
        <td class="c1 text ">
          <label for="resp16292_61942">
            <span class="anun">c<span class="anumsep">.</span></span> 012.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16292_61943" name="resp16292_" type="radio" value="61943">        </td>
        <td class="c1 text ">
          <label for="resp16292_61943">
            <span class="anun">d<span class="anumsep">.</span></span> 111.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16292_61944" name="resp16292_" type="radio" value="61944">        </td>
        <td class="c1 text ">
          <label for="resp16292_61944">
            <span class="anun">e<span class="anumsep">.</span></span> 011.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : A <br><br>Explanation: <br>The value of j becomes 0 because of the assignment j=--i. <br><br>The expression j/=i throws an ArithmeticException, since i=0. Since RuntimeException is the superclass of ArithmeticException, it can be used in the catch clause. <br><br>In the catch clause j is incremented by 1 and printed, so the output is 1. In the finally clause, j is printed first and then incremented, so the output is 1 again. <br><br>After the execution of the finally block, control passes to the next statement, where the value of j is again printed as 2.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2042%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5497" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                42      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Suppose MyException (which is a subclass of Exception) should be thrown if condition (which is a boolean variable) is true, which statements would you insert? Select two choices.<br><br>1. public aMethod <br>2. {<br> 3. if (condition) {<br> 4.<br> 5. } <br>6. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5497_23467" name="resp5497_23467" type="checkbox" value="23467">        </td>
        <td class="c1 text ">
          <label for="resp5497_23467">
            <span class="anun">a<span class="anumsep">.</span></span> throw new Exception() at line 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5497_23468" name="resp5497_23468" checked="checked" type="checkbox" value="23468">        </td>
        <td class="c1 text correct">
          <label for="resp5497_23468">
            <span class="anun">b<span class="anumsep">.</span></span> throw new MyException() at line 4            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5497_23469" name="resp5497_23469" type="checkbox" value="23469">        </td>
        <td class="c1 text ">
          <label for="resp5497_23469">
            <span class="anun">c<span class="anumsep">.</span></span> throw new MyException() at line 6            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5497_23470" name="resp5497_23470" type="checkbox" value="23470">        </td>
        <td class="c1 text ">
          <label for="resp5497_23470">
            <span class="anun">d<span class="anumsep">.</span></span> throws new Exception() at line 3            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5497_23471" name="resp5497_23471" checked="checked" type="checkbox" value="23471">        </td>
        <td class="c1 text correct">
          <label for="resp5497_23471">
            <span class="anun">e<span class="anumsep">.</span></span> throws MyException at line 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B and E are the correct answers.<br><br> If a method throws a checked exception (MyException, in this case), it must be caught using a try/catch block or declared in the throws clause of the method. This must be at line 1, as part of the method declaration. So choice E is correct. <br><br>Choice B is correct because the exception must be thrown using the throw keyword within the body of the if statement, which will be executed provided the condition is true. <br><br>Choice A is incorrect because it must be 'throws' instead of 'throw' on line 1. <br><br>Choice C is incorrect because throw statement is not given at line 6, but at line 4. <br><br>Choice D is incorrect because it should be 'throw' instead of 'throws' here. <br><br>Reference: <a href="http://java.sun.com/docs/books/tutorial/essential/exceptions/">http://java.sun.com/docs/books/tutorial/essential/exceptions/</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2043%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5498" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                43      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following program? <br><br>class Test <br>{ <br>
<div style="margin-left: 40px;">void f() throws NullPointerException<br>{ <br>
  <div style="margin-left: 40px;">throw new RuntimeException(); <br></div>} <br>public static void main (String[] args) throws Exception <br>{ <br>
  <div style="margin-left: 40px;">Test t=new Test(); <br>try <br>{<br>
    <div style="margin-left: 40px;"> t.f(); <br></div>} <br>catch (Exception e) <br>{ <br>
    <div style="margin-left: 40px;">System.out.println("catch"); <br></div>} <br>finally <br>{ <br>
    <div style="margin-left: 40px;">System.out.println("finally"); <br>throw e; <br></div>} <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5498_23472" name="resp5498_" checked="checked" type="radio" value="23472">        </td>
        <td class="c1 text ">
          <label for="resp5498_23472">
            <span class="anun">a<span class="anumsep">.</span></span> Code does not compile because f() does not declare that it throws RuntimeException.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5498_23473" name="resp5498_" type="radio" value="23473">        </td>
        <td class="c1 text ">
          <label for="resp5498_23473">
            <span class="anun">b<span class="anumsep">.</span></span> Compiles and prints "catch finally".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5498_23474" name="resp5498_" type="radio" value="23474">        </td>
        <td class="c1 text ">
          <label for="resp5498_23474">
            <span class="anun">c<span class="anumsep">.</span></span> Compiles and prints "finally".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5498_23475" name="resp5498_" type="radio" value="23475">        </td>
        <td class="c1 text ">
          <label for="resp5498_23475">
            <span class="anun">d<span class="anumsep">.</span></span> Compiles and prints "catch".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5498_23476" name="resp5498_" type="radio" value="23476">        </td>
        <td class="c1 text ">
          <label for="resp5498_23476">
            <span class="anun">e<span class="anumsep">.</span></span> Compiles and runs without output.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5498_23477" name="resp5498_" type="radio" value="23477">        </td>
        <td class="c1 text correct">
          <label for="resp5498_23477">
            <span class="anun">f<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice F is the correct answer. <br><br>The code does not compile because the variable e is not accessible inside the finally block. The scope of the variable is limited to the catch block. <br><br>RuntimeException and its subclasses do not need to be declared by a method even if it is throwing that exception. So choice A is incorrect. <br><br>Since the code does not compile, all the other choices are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2044%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5499" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                44      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile and run the following code? <br>(Assume that the code is compiled and run with assertions enabled.) <br> 1. public class AssertDemo <br>2. { <br>3. private static boolean isValid(int i) <br>4. { <br>5. return 10%i &gt; 0; <br>6. }<br>7. <br>8. public static void main(String[] args) <br>9. { <br>10. int i = 0; <br>11. assert isValid(i) : "Invalid value"; <br>12. System.out.println(i); <br>13. } <br>14. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5499_23478" name="resp5499_" type="radio" value="23478">        </td>
        <td class="c1 text ">
          <label for="resp5499_23478">
            <span class="anun">a<span class="anumsep">.</span></span> It will print-0            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5499_23479" name="resp5499_" type="radio" value="23479">        </td>
        <td class="c1 text ">
          <label for="resp5499_23479">
            <span class="anun">b<span class="anumsep">.</span></span> Compilation error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5499_23480" name="resp5499_" type="radio" value="23480">        </td>
        <td class="c1 text ">
          <label for="resp5499_23480">
            <span class="anun">c<span class="anumsep">.</span></span> It will throw an AssertionError with message : Invalid value.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5499_23481" name="resp5499_" checked="checked" type="radio" value="23481">        </td>
        <td class="c1 text correct">
          <label for="resp5499_23481">
            <span class="anun">d<span class="anumsep">.</span></span> It will throw an ArithmeticException.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5499_23482" name="resp5499_" type="radio" value="23482">        </td>
        <td class="c1 text ">
          <label for="resp5499_23482">
            <span class="anun">e<span class="anumsep">.</span></span> None of these.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br>The code will throw an ArithmeticException: / by zero (divide by zero) at runtime. Code at line 5 throws a runtime exception, the assert statement completes abruptly. The remaining statements will not be executed. Let's look at the execution of the code. The assert statement at line 11 calls the isValid(int i) with an argument 0. This method causes an ArithmeticException divide by zero at line 5. Since the method causes an exception to be thrown, the boolean value is not returned to the calling assert statement and hence the assert statement completes abruptly. <br>Thus an AssertionError will not be thrown. Choice B is incorrect because there is nothing wrong with the code as far as compilation is concerned. Using a method call as the first expressions of assert statement is perfectly valid as long as the method returns a primitive boolean or a Boolean object. Also, since the main method is part of the class, it can always call another static method without requiring a class instance irrespective of the access modifier of the method. It is important to understand when and how to use the assert statement, and the conditions under which it might complete abruptly. In case of an assert statement of type - assert boolean_expression : secondary_expression; If an exception is thrown while either of the expressions is being evaluated, the assert statement completes abruptly, throwing this exception. <br><br>Reference: http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2045%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5501" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                45      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Assume that assertions are enabled at both compiletime and runtime. <br>Given an assert statement - <br><br>assert Expression1 : Expression2; <br><br>Which of the following statements are true about Expression1? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5501_23487" name="resp5501_23487" checked="checked" type="checkbox" value="23487">        </td>
        <td class="c1 text correct">
          <label for="resp5501_23487">
            <span class="anun">a<span class="anumsep">.</span></span> It always gets evaluated.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5501_23488" name="resp5501_23488" type="checkbox" value="23488">        </td>
        <td class="c1 text ">
          <label for="resp5501_23488">
            <span class="anun">b<span class="anumsep">.</span></span> It cannot be a method call.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5501_23489" name="resp5501_23489" type="checkbox" value="23489">        </td>
        <td class="c1 text ">
          <label for="resp5501_23489">
            <span class="anun">c<span class="anumsep">.</span></span> It can also be a method call to any method.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5501_23490" name="resp5501_23490" checked="checked" type="checkbox" value="23490">        </td>
        <td class="c1 text correct">
          <label for="resp5501_23490">
            <span class="anun">d<span class="anumsep">.</span></span> It must be a boolean or Boolean expression.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and D are the correct answers.<br><br> Whenever assertions are enabled, the expression Expression1 always gets evaluated, and depending on result of Expression1 (true or false), the Expression2 may or may not get evaluated. Also, this expression must be of type boolean or Boolean, which is also now allowed since it gets boxed to boolean. <br><br>Expression1 can be a method call if and only if that method returns a boolean primitive or a Boolean object, and not otherwise. Hence, choices B and C are not correct.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2046%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5502" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                46      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the output when you compile and execute the following program? <br><br>public class Base <br>{ <br>
<div style="margin-left: 40px;">private void test() <br>{ <br>
  <div style="margin-left: 40px;">int i = 66; <br>switch (i) <br>{ <br>
    <div style="margin-left: 40px;">case 'A': <br>
      <div style="margin-left: 40px;">System.out.print("zero"); <br>break; <br></div>case 'B': <br>
      <div style="margin-left: 40px;">System.out.print("one"); <br></div>case 'C': <br>
      <div style="margin-left: 40px;">System.out.print("two"); <br></div>default:<br>
      <div style="margin-left: 40px;">System.out.print("default"); <br></div>case 66:<br>
      <div style="margin-left: 40px;">System.out.print("66"); <br></div></div>} <br></div>} <br>static public void main(String[] a) <br>{ <br>
  <div style="margin-left: 40px;">new Base().test(); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5502_23491" name="resp5502_" type="radio" value="23491">        </td>
        <td class="c1 text ">
          <label for="resp5502_23491">
            <span class="anun">a<span class="anumsep">.</span></span> one            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5502_23492" name="resp5502_" type="radio" value="23492">        </td>
        <td class="c1 text ">
          <label for="resp5502_23492">
            <span class="anun">b<span class="anumsep">.</span></span> one default            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5502_23493" name="resp5502_" type="radio" value="23493">        </td>
        <td class="c1 text ">
          <label for="resp5502_23493">
            <span class="anun">c<span class="anumsep">.</span></span> one two default            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5502_23494" name="resp5502_" type="radio" value="23494">        </td>
        <td class="c1 text ">
          <label for="resp5502_23494">
            <span class="anun">d<span class="anumsep">.</span></span> default            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5502_23495" name="resp5502_" type="radio" value="23495">        </td>
        <td class="c1 text ">
          <label for="resp5502_23495">
            <span class="anun">e<span class="anumsep">.</span></span> Compilation Error - switch cannot take char type as argument            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5502_58140" name="resp5502_" type="radio" value="58140">        </td>
        <td class="c1 text ">
          <label for="resp5502_58140">
            <span class="anun">f<span class="anumsep">.</span></span> one two default 66            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5502_58141" name="resp5502_" type="radio" value="58141">        </td>
        <td class="c1 text ">
          <label for="resp5502_58141">
            <span class="anun">g<span class="anumsep">.</span></span> 66            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5502_58142" name="resp5502_" checked="checked" type="radio" value="58142">        </td>
        <td class="c1 text correct">
          <label for="resp5502_58142">
            <span class="anun">h<span class="anumsep">.</span></span> Compilation Error due to some other reason            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice H is the correct answer. <br><br>The char type has an integer representation given by its ASCII code. The ASCII code for the character 'B' is 66, so in the given code, the matching case is case 'B' and also case 66. Due to presence of duplicate cases, compilation error is there. So choices A, B, C, D, F and G are incorrect. <br><br>The argument to the switch statement can be a byte, a short, a char, an int or an enum constant, so choice E is incorrect. <br><br>More information is available at: <br><a href="http://java.sun.com/docs/books/jls/third_edition/html/statements.html#%7C14.11">http://java.sun.com/docs/books/jls/third_edition/html/statements.html#|14.11</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2047%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5503" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                47      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile/run the following code? <br><br>public class MyClass <br>{ <br>
<div style="margin-left: 40px;">public static void main (String[] args) <br>{ <br>
  <div style="margin-left: 40px;">int total = 0; <br>for (int i = 0, j = 10; total &gt; 30; ++i, --j) <br>{ <br>
    <div style="margin-left: 40px;">System.out.println(" i = " + i + " : j = " + j); <br>total += (i + j); <br></div>} <br>System.out.println("Total " + total); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5503_23496" name="resp5503_" type="radio" value="23496">        </td>
        <td class="c1 text ">
          <label for="resp5503_23496">
            <span class="anun">a<span class="anumsep">.</span></span> Produces a runtime error.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5503_23497" name="resp5503_" type="radio" value="23497">        </td>
        <td class="c1 text ">
          <label for="resp5503_23497">
            <span class="anun">b<span class="anumsep">.</span></span> Produces a compile time error.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5503_23498" name="resp5503_" checked="checked" type="radio" value="23498">        </td>
        <td class="c1 text correct">
          <label for="resp5503_23498">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "Total 0".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5503_23499" name="resp5503_" type="radio" value="23499">        </td>
        <td class="c1 text ">
          <label for="resp5503_23499">
            <span class="anun">d<span class="anumsep">.</span></span> Prints<br>&nbsp;&nbsp;&nbsp;&nbsp;i = 0 : j = 10 <br>&nbsp;&nbsp;&nbsp;&nbsp;i = 1 : j = 9  <br>&nbsp;&nbsp;&nbsp;&nbsp;i = 2 : j = 8  <br>&nbsp;&nbsp;&nbsp;&nbsp;Total 30            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>The code can be easily overlooked and needs proper concentration. <br><br>Please note that in the for loop, the test expression is 'total &gt; 30' and not 'total &lt; 30'. <br><br>Thus, the for loop will not be executed at all. And "Total 0" will be printed out. Thus choice D is incorrect. <br><br>The code compiles and runs without errors, so choices A and B are also incorrect. <br><br>Reference: <a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html">http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2048%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16294" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                48      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output of the following code. <br><br>class Test <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br></div>
<div style="margin-left: 40px;"> { <br></div>
<div style="margin-left: 80px;">Integer x = 9; <br><br>int y = 5; <br>x/=x; <br>y*=y; <br>y+=y; <br>x-=y; <br><br>System.out.println(x); <br></div>
<div style="margin-left: 40px;">} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16294_61950" name="resp16294_" type="radio" value="61950">        </td>
        <td class="c1 text ">
          <label for="resp16294_61950">
            <span class="anun">a<span class="anumsep">.</span></span> 50.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16294_61951" name="resp16294_" type="radio" value="61951">        </td>
        <td class="c1 text ">
          <label for="resp16294_61951">
            <span class="anun">b<span class="anumsep">.</span></span> Compilation error.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16294_61952" name="resp16294_" type="radio" value="61952">        </td>
        <td class="c1 text ">
          <label for="resp16294_61952">
            <span class="anun">c<span class="anumsep">.</span></span> Exception at runtime.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16294_61953" name="resp16294_" checked="checked" type="radio" value="61953">        </td>
        <td class="c1 text correct">
          <label for="resp16294_61953">
            <span class="anun">d<span class="anumsep">.</span></span> 49.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16294_61954" name="resp16294_" type="radio" value="61954">        </td>
        <td class="c1 text ">
          <label for="resp16294_61954">
            <span class="anun">e<span class="anumsep">.</span></span> 48.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : D <br><br>Explanation: <br>This question demonstrates the use of overloaded assignment operators. <br><br>Autoboxing allows the conversion of Integer into int type, so Integer and int can be used in the same expression. <br><br>The expression x/=x is the same as x=(x/x)=9/9=1. <br><br>The next expression y*=y is evaluated as y=y*y=5*5=25. <br><br>The expression y+=y becomes y=y+y=25+25=50. <br><br>Finally, x-=y results in x=x-y=1-50=-49.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2049%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16296" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                49      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Choose the option which contains the access specifiers in order from least to most restrictive.</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16296_61959" name="resp16296_" type="radio" value="61959">        </td>
        <td class="c1 text ">
          <label for="resp16296_61959">
            <span class="anun">a<span class="anumsep">.</span></span> protected, public, no modifier, private.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16296_61960" name="resp16296_" checked="checked" type="radio" value="61960">        </td>
        <td class="c1 text correct">
          <label for="resp16296_61960">
            <span class="anun">b<span class="anumsep">.</span></span>  public, protected, no modifier, private.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16296_61961" name="resp16296_" type="radio" value="61961">        </td>
        <td class="c1 text ">
          <label for="resp16296_61961">
            <span class="anun">c<span class="anumsep">.</span></span> public, no modifier, protected, private.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16296_61962" name="resp16296_" type="radio" value="61962">        </td>
        <td class="c1 text ">
          <label for="resp16296_61962">
            <span class="anun">d<span class="anumsep">.</span></span> no modifier, public, protected, private.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : B <br><br>Explanation: <br>Members of a class are accessible to any class within any package if they are declared public. <br><br>The protected members are accessible with in the same package and to sub classes in other package . <br><br>Members with no access modifier have package access only, i.e. only to other classes in the same package as their declaring class. <br><br>The most restrictive are the private members whose visibility is limited to the declaring class.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2050%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5504" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                50      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of running the following code? <br><br>public class Short <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">int a = 0; <br>StringBuffer s = new StringBuffer("Hello"); <br>if ((s.length() &lt; 10) | (s.append(" world").equals("Well done"))) ; <br>
    <div style="margin-left: 40px;">// do nothing <br></div>System.out.println("Value is - " + s); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5504_23500" name="resp5504_" type="radio" value="23500">        </td>
        <td class="c1 text ">
          <label for="resp5504_23500">
            <span class="anun">a<span class="anumsep">.</span></span> The output: Value is - Hello            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5504_23501" name="resp5504_" checked="checked" type="radio" value="23501">        </td>
        <td class="c1 text correct">
          <label for="resp5504_23501">
            <span class="anun">b<span class="anumsep">.</span></span> The output: Value is - Hello world            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5504_23502" name="resp5504_" type="radio" value="23502">        </td>
        <td class="c1 text ">
          <label for="resp5504_23502">
            <span class="anun">c<span class="anumsep">.</span></span> A compiler error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5504_23503" name="resp5504_" type="radio" value="23503">        </td>
        <td class="c1 text ">
          <label for="resp5504_23503">
            <span class="anun">d<span class="anumsep">.</span></span> No output            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5504_23504" name="resp5504_" type="radio" value="23504">        </td>
        <td class="c1 text ">
          <label for="resp5504_23504">
            <span class="anun">e<span class="anumsep">.</span></span> An exception            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer. <br><br>Since the OR operator used here is not the short-circuit operator (which is "||"), both operands are evaluated even though the first operand itself is true which guarantees that the whole condition is true. Thus the value of the StringBuffer instance s after the evaluation of the boolean condition is "Hello world" and hence choice B is correct. <br><br>Please note here that if we had used "||" operator instead of "|", the correct answer would have been choice A, because in that case the right-hand side operand wouldn't have been evaluated as the left-hand side operand would have been true.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2051%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5506" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                51      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following modifiers can be applied to a top-level class (i.e. a class which is not enclosed in another class)? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5506_23511" name="resp5506_23511" type="checkbox" value="23511">        </td>
        <td class="c1 text ">
          <label for="resp5506_23511">
            <span class="anun">a<span class="anumsep">.</span></span> private            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5506_23512" name="resp5506_23512" type="checkbox" value="23512">        </td>
        <td class="c1 text ">
          <label for="resp5506_23512">
            <span class="anun">b<span class="anumsep">.</span></span> protected            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5506_23513" name="resp5506_23513" type="checkbox" value="23513">        </td>
        <td class="c1 text ">
          <label for="resp5506_23513">
            <span class="anun">c<span class="anumsep">.</span></span> transient            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5506_23514" name="resp5506_23514" checked="checked" type="checkbox" value="23514">        </td>
        <td class="c1 text correct">
          <label for="resp5506_23514">
            <span class="anun">d<span class="anumsep">.</span></span> public            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5506_23515" name="resp5506_23515" checked="checked" type="checkbox" value="23515">        </td>
        <td class="c1 text correct">
          <label for="resp5506_23515">
            <span class="anun">e<span class="anumsep">.</span></span> final            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices D and E are the correct answers.<br><br> Top-level classes can be declared public, which allows classes from all packages to access them. Declaring a class final prevents other classes from extending it. <br><br>transient is a keyword used for preventing variables in an object from being serialized. It cannot be applied to classes. Top-level classes cannot be declared as private. <br><br>The keyword "protected" only applies to members including variables, methods and nested classes, and is used to restrict access to the classes in the same package or subclasses. <br><br>Thus, choices D and E are correct and all other choices are incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2052%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5507" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                52      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following code? <br><br>class Test<br>{ <br>
<div style="margin-left: 40px;">final int x; <br>int y=5; <br>Test(int i) <br>{ <br>
  <div style="margin-left: 40px;">y=x+i; <br></div>} <br>public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">Test t=new Test(10); <br>System.out.println(t.y); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5507_23516" name="resp5507_" type="radio" value="23516">        </td>
        <td class="c1 text correct">
          <label for="resp5507_23516">
            <span class="anun">a<span class="anumsep">.</span></span> Code does not compile.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5507_23517" name="resp5507_" checked="checked" type="radio" value="23517">        </td>
        <td class="c1 text ">
          <label for="resp5507_23517">
            <span class="anun">b<span class="anumsep">.</span></span> Prints 10.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5507_23518" name="resp5507_" type="radio" value="23518">        </td>
        <td class="c1 text ">
          <label for="resp5507_23518">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 5.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5507_23519" name="resp5507_" type="radio" value="23519">        </td>
        <td class="c1 text ">
          <label for="resp5507_23519">
            <span class="anun">d<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>The given code does not compile because final instance variables have to be explicitly initialized by the time the constructor has completed. <br><br>Only non-final instance variables are initialized to their default values. So here the compiler will complain that x is not initialized. <br><br>If x had been non-final, the code would have printed 10.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2053%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5508" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                53      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Given the following. <br><br>package p1;<br><br> public class Fruit<br> { <br>
<div style="margin-left: 40px;">protected String taste; <br>protected void changeColor() {} <br></div>}<br><br> package p2; <br>public class Apple extends Fruit { ? }<br><br> Which of the following may be legally placed inside Apple? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5508_23520" name="resp5508_23520" type="checkbox" value="23520">        </td>
        <td class="c1 text ">
          <label for="resp5508_23520">
            <span class="anun">a<span class="anumsep">.</span></span> protected int changeColor(){}            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5508_23521" name="resp5508_23521" type="checkbox" value="23521">        </td>
        <td class="c1 text correct">
          <label for="resp5508_23521">
            <span class="anun">b<span class="anumsep">.</span></span> {  	taste="sweet";     }            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5508_23522" name="resp5508_23522" type="checkbox" value="23522">        </td>
        <td class="c1 text ">
          <label for="resp5508_23522">
            <span class="anun">c<span class="anumsep">.</span></span> void changeColor() {}            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5508_23523" name="resp5508_23523" type="checkbox" value="23523">        </td>
        <td class="c1 text ">
          <label for="resp5508_23523">
            <span class="anun">d<span class="anumsep">.</span></span> {  	(new Fruit()).taste="sweet";     }            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5508_23524" name="resp5508_23524" checked="checked" type="checkbox" value="23524">        </td>
        <td class="c1 text correct">
          <label for="resp5508_23524">
            <span class="anun">e<span class="anumsep">.</span></span> protected void changeColor() throws RuntimeException            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B and E are the correct answers.<br><br> The protected variable taste in the class Fruit is available in class Apple even though it is in a different package, since Apple extends Fruit. <br><br>However, choice D will not compile because it accesses the field taste of a Fruit instance, which is not allowed. <br><br>Choice E is correct because there is no restriction on throwing RuntimeException in overriding methods. <br><br>Choice A will not compile because the return type is different in the changeColor method, while the argument list matches. <br><br>Choice C will not compile because protected methods cannot be overridden by methods with default access.      </div>
        <div class="grading">
      <div class="correctness  partiallycorrect">Partially correct</div><div class="gradingdetails">Marks for this submission: 0.5/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2054%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5509" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                54      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile and run the following code? <br><br>interface MyInterface { } <br>public class MyInstanceTest implements MyInterface <br>{ <br>
<div style="margin-left: 40px;">static String s; <br>public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">MyInstanceTest t = new MyInstanceTest(); <br>if(t instanceof MyInterface) <br>{ <br>
    <div style="margin-left: 40px;">System.out.println("I am true interface"); <br></div>} <br>else <br>{ <br>
    <div style="margin-left: 40px;">System.out.println("I am false interface"); <br></div>} <br>if(s instanceof String) <br>{ <br>
    <div style="margin-left: 40px;">System.out.println("I am true String"); <br></div>} <br>else <br>{ <br>
    <div style="margin-left: 40px;">System.out.println("I am false String"); <br></div>} <br></div>}<br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5509_23525" name="resp5509_" type="radio" value="23525">        </td>
        <td class="c1 text ">
          <label for="resp5509_23525">
            <span class="anun">a<span class="anumsep">.</span></span> compile time error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5509_23526" name="resp5509_" type="radio" value="23526">        </td>
        <td class="c1 text ">
          <label for="resp5509_23526">
            <span class="anun">b<span class="anumsep">.</span></span> Runtime error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5509_23527" name="resp5509_" type="radio" value="23527">        </td>
        <td class="c1 text ">
          <label for="resp5509_23527">
            <span class="anun">c<span class="anumsep">.</span></span> Prints : "I am true interface" followed by "I am true String".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5509_23528" name="resp5509_" type="radio" value="23528">        </td>
        <td class="c1 text ">
          <label for="resp5509_23528">
            <span class="anun">d<span class="anumsep">.</span></span> Prints : "I am false interface" followed by "I am false String".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5509_23529" name="resp5509_" checked="checked" type="radio" value="23529">        </td>
        <td class="c1 text correct">
          <label for="resp5509_23529">
            <span class="anun">e<span class="anumsep">.</span></span> Prints : "I am true interface" followed by "I am false String".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5509_23530" name="resp5509_" type="radio" value="23530">        </td>
        <td class="c1 text ">
          <label for="resp5509_23530">
            <span class="anun">f<span class="anumsep">.</span></span> Prints : "I am false interface" followed by "I am true String".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice E is the correct answer. <br><br>The "instanceof" operator tests the class of an object at runtime. It returns true if the class of the left-hand argument is the same as, or is some subclass of, the class specified by the right-hand operand. The right-hand operand may equally well be an interface. In such a case, the test determines if the object at left-hand argument implements the specified interface. <br><br>In the given case there will not be any compile time or runtime error. The result of "t instanceof MyInterface" will be true as "t" is the object of MyInstanceTest class, which implements the MyInstance interface. But the result of "s instanceof String" will be false as "s" refers to null. <br><br>Thus the output of the above program will be: "I am true interface" followed by "I am false String". <br><br>Thus, choice E is correct and others are incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2055%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5511" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                55      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which option is true about compiling and running the following code? <br><br>class SuperTest <br>{ <br>
<div style="margin-left: 40px;">protected void finalize() <br>{ <br>
  <div style="margin-left: 40px;">super.finalize(); //1 <br>System.out.println("SuperTest"); <br></div>} <br></div>} <br><br>public class Test extends SuperTest <br>{ <br>
<div style="margin-left: 40px;">String s="abc"; <br>public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">Test t=new Test(); //2 <br>t.finalize(); //3 <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5511_23536" name="resp5511_" checked="checked" type="radio" value="23536">        </td>
        <td class="c1 text correct">
          <label for="resp5511_23536">
            <span class="anun">a<span class="anumsep">.</span></span> Code will compile only if line 1 is removed.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5511_23537" name="resp5511_" type="radio" value="23537">        </td>
        <td class="c1 text ">
          <label for="resp5511_23537">
            <span class="anun">b<span class="anumsep">.</span></span> Code will compile only if line 3 is removed.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5511_23538" name="resp5511_" type="radio" value="23538">        </td>
        <td class="c1 text ">
          <label for="resp5511_23538">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "SuperTest".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5511_23539" name="resp5511_" type="radio" value="23539">        </td>
        <td class="c1 text ">
          <label for="resp5511_23539">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "SuperTest" only if garbage collector runs.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5511_23540" name="resp5511_" type="radio" value="23540">        </td>
        <td class="c1 text ">
          <label for="resp5511_23540">
            <span class="anun">e<span class="anumsep">.</span></span> Causes an exception to be thrown at runtime.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5511_23541" name="resp5511_" type="radio" value="23541">        </td>
        <td class="c1 text ">
          <label for="resp5511_23541">
            <span class="anun">f<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>Here the code will compile only if line 1 is removed. <br><br>The super.finalize() method call invokes the finalize() method defined in the Object class. <br><br>The finalize() method in the Object class throws Throwable, and since it is not handled at line 1, the code will not compile. <br><br>There is no error in line 3. It is valid to invoke the finalize() method directly. <br><br>If line 1 is removed, the code will compile and print "SuperTest".      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2056%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5492" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                56      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following program? <br><br>class Parent <br>{ <br>
<div style="margin-left: 40px;">static int i=10; <br>void m1() <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("In parent "+i); <br></div>} <br>static void m1(String s) <br>{ <br>
  <div style="margin-left: 40px;">System.out.println(s+i); <br></div>} <br></div>} <br>class Child extends Parent <br>{ <br>
<div style="margin-left: 40px;">static int i=20; <br>void m1() <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("In child "+Child.i); <br></div>} <br>public static void main (String[] args) <br>{ <br>
  <div style="margin-left: 40px;">Parent p=new Child(); <br>p.m1(); <br>System.out.println("Child data "+p.i); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5492_23442" name="resp5492_" type="radio" value="23442">        </td>
        <td class="c1 text ">
          <label for="resp5492_23442">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5492_23443" name="resp5492_" checked="checked" type="radio" value="23443">        </td>
        <td class="c1 text correct">
          <label for="resp5492_23443">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "In Child 20" followed by "Child data 10".                <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5492_23444" name="resp5492_" type="radio" value="23444">        </td>
        <td class="c1 text ">
          <label for="resp5492_23444">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "In Child 20" followed by "Child data 20".            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5492_23445" name="resp5492_" type="radio" value="23445">        </td>
        <td class="c1 text ">
          <label for="resp5492_23445">
            <span class="anun">d<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer. <br><br>Here we have overridden the method m1() in the Child class. The variable i in the Parent class is hidden by the variable i in the Child class. <br><br>Now using the Parent class reference, we invoke the method m1. This reference holds a Child type object at runtime, so the method invoked is the overridden m1() in the Child class. It prints the value of the variable i as defined in the Child class ie; with a value of 20. <br><br>Now when we try to access the variable i directly, it gets the base class version of i. This is because there is no overriding in the case of variables. The variable is chosen at compile time itself, based on the reference variable type used to access the variable. <br><br>In this case, the reference variable is of type Parent, so the variable chosen is the variable from the Parent class with a value of 10. So the output is "In Child 20" followed by "Child data 10"      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2057%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5514" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                57      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the given code? <br><br>class A<br>{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print("A"); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>} <br>class B extends A<br>{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B() <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this(4); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print("B"); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B(int i)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print("C"); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5514_23551" name="resp5514_" checked="checked" type="radio" value="23551">        </td>
        <td class="c1 text correct">
          <label for="resp5514_23551">
            <span class="anun">a<span class="anumsep">.</span></span> Does not compile            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5514_23552" name="resp5514_" type="radio" value="23552">        </td>
        <td class="c1 text ">
          <label for="resp5514_23552">
            <span class="anun">b<span class="anumsep">.</span></span> Prints  "ABC"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5514_23553" name="resp5514_" type="radio" value="23553">        </td>
        <td class="c1 text ">
          <label for="resp5514_23553">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "ACB"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5514_23554" name="resp5514_" type="radio" value="23554">        </td>
        <td class="c1 text ">
          <label for="resp5514_23554">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "CAB"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>The code does not compile because super() call must be the first statement within the constructor. The same rule applies for this() method call also, so both super() and this() calls cannot be made within the same constructor. Since the code does not compile, all the other choices are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2058%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5515" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                58      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following program? <br><br>interface I {int i=0;} <br>class A implements I <br>{ <br>
<div style="margin-left: 40px;">int i=I.i+1;<br></div>} <br>class B extends A <br>{ <br>
<div style="margin-left: 40px;">int i=I.i+2; <br>static void printAll(A obj) <br>{ <br>
  <div style="margin-left: 40px;">System.out.print(obj.i); <br></div>} <br>public static void main (String[] args) <br>{ <br>
  <div style="margin-left: 40px;">B b=new B(); <br>A a=new B(); <br>I i=new B(); <br>printAll(b); <br>printAll(a); <br>printAll(i); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5515_23555" name="resp5515_" checked="checked" type="radio" value="23555">        </td>
        <td class="c1 text correct">
          <label for="resp5515_23555">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler Error            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5515_23556" name="resp5515_" type="radio" value="23556">        </td>
        <td class="c1 text ">
          <label for="resp5515_23556">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "000"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5515_23557" name="resp5515_" type="radio" value="23557">        </td>
        <td class="c1 text ">
          <label for="resp5515_23557">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "222"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5515_23558" name="resp5515_" type="radio" value="23558">        </td>
        <td class="c1 text ">
          <label for="resp5515_23558">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "210"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5515_23559" name="resp5515_" type="radio" value="23559">        </td>
        <td class="c1 text ">
          <label for="resp5515_23559">
            <span class="anun">e<span class="anumsep">.</span></span> None of the above            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>This code will not compile because the function printAll() takes an argument of type A. We declare a variable of type I in the main function and try to pass it to the printAll() function. <br><br>Note that I cannot be passed where A is expected because A is implementing I. <br><br>An interface/superclass reference can be assigned a subclass reference but the opposite is not allowed. So the compiler complains that the methods don't match.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2059%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5516" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                59      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will appear in the standard output when you run the Tester class?<br>
 <br>
 1.      class Tester <br>
 2.      {<br>
 3.              int var;<br>
 4.              Tester(double var) <br>
 5.              {<br>
 6.                              this.var = (int)var;<br>
 7.              }<br>
 8.              Tester(int var) <br>
 9.              {<br>
 10.                             this("hello");<br>
 11.             }<br>
 12.             Tester(String s) <br>
 13.             {<br>
 10.                             this();<br>
 11.                             System.out.println(s);<br>
 12.             }<br>
 13.             Tester() <br>
 14.             {<br>
 15.                             System.out.println("good-bye");<br>
 16.             }<br>
 17.             public static void main(String[] args) <br>
 18.             {<br>
 19.                             Tester t = new Tester(5);<br>
 20.             }<br>
 21.     }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5516_23560" name="resp5516_" type="radio" value="23560">        </td>
        <td class="c1 text ">
          <label for="resp5516_23560">
            <span class="anun">a<span class="anumsep">.</span></span> "hello"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5516_23561" name="resp5516_" type="radio" value="23561">        </td>
        <td class="c1 text ">
          <label for="resp5516_23561">
            <span class="anun">b<span class="anumsep">.</span></span> 5            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5516_23562" name="resp5516_" type="radio" value="23562">        </td>
        <td class="c1 text ">
          <label for="resp5516_23562">
            <span class="anun">c<span class="anumsep">.</span></span> "hello" followed by "good-bye"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5516_23563" name="resp5516_" checked="checked" type="radio" value="23563">        </td>
        <td class="c1 text correct">
          <label for="resp5516_23563">
            <span class="anun">d<span class="anumsep">.</span></span> "good-bye" followed by "hello"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br>
 <br>
 From the main() method, first the constructor Tester(int var) is called, which in turn calls the constructor Tester(String s) with "hello" as parameter. This constructor then calls the constructor Tester() which prints "good-bye". After this the execution goes back to the constructor Tester(String s), which prints "hello". Therefore choice D is correct and all the other choices are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2060%20of%20Quiz%20Practice%20Test%20IV%20(ID:%201777),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5518" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                60      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following program? <br><br>class A <br>{ <br>
<div style="margin-left: 40px;">static void f() <br>{ <br>
  <div style="margin-left: 40px;">System.out.print("Inside A ");<br></div>} <br></div>} <br>class B extends A <br>{ <br>
<div style="margin-left: 40px;">static void f() <br>{ <br>
  <div style="margin-left: 40px;">System.out.print("Inside B ");<br></div>} <br></div>} <br>class C extends B <br>{ <br>
<div style="margin-left: 40px;">static void f() <br>{ <br>
  <div style="margin-left: 40px;">System.out.print("Inside C ");<br></div>} <br></div>} <br>class D <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">C c = new C(); <br>c.f(); <br>B b = c; <br>b.f(); <br>A a = (B)c; <br>a.f(); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5518_23569" name="resp5518_" checked="checked" type="radio" value="23569">        </td>
        <td class="c1 text correct">
          <label for="resp5518_23569">
            <span class="anun">a<span class="anumsep">.</span></span> Prints "Inside C Inside B Inside A"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5518_23570" name="resp5518_" type="radio" value="23570">        </td>
        <td class="c1 text ">
          <label for="resp5518_23570">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "Inside"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5518_23571" name="resp5518_" type="radio" value="23571">        </td>
        <td class="c1 text ">
          <label for="resp5518_23571">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "Inside C Inside C"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5518_23572" name="resp5518_" type="radio" value="23572">        </td>
        <td class="c1 text ">
          <label for="resp5518_23572">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "Inside C Inside C Inside B"            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5518_23573" name="resp5518_" type="radio" value="23573">        </td>
        <td class="c1 text ">
          <label for="resp5518_23573">
            <span class="anun">e<span class="anumsep">.</span></span> None of the above            <img src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>Here we have to note that static methods are not actually overridden, i.e. the method invoked is based on the reference variable type and not on the actual object type at runtime. So in all the three invocations, though the actual invoking object is of type C, the reference variable types are different. <br><br>First it is C, then B and then A. <br><br>So the output is "Inside C Inside B Inside A". <br><br>To know more about this, check out: <a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#|8.4.8.2">http://java.sun.com/docs/books/jls/third_edition/html/classes.html#|8.4.8.2</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>

<div class="controls">
<div class="singlebutton"><form action="http://www.whizlabs.com/examprep/mod/quiz/view.php" method="get"><div><input type="hidden" name="id" value="2205"><input type="submit" value="Finish review"></div></form></div></div>
<!--Start - Display Buttons with their course prices in each moodle pages: Devesh M-->
				
		<!--Start - Display Buy Mock Exam Full Version button with price at trial course page only: Devesh M-->
				<!--End - Display Buy Mock Exam Full Version button with price at trial course page only: Devesh M-->
  <div id="leftfooter" style="display: none; "></div><div id="rightfooter" style="display: none; "><p class="footertopma">Thanks Whizlabs for such an excellent product. It really helped me a lot for my achivement. -Nazmul<span class="more"><a href="http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170804&showall=true#" class="amore"> more</a></span></p>

  </div>

  <div id="rightfooter2" style="display: none; "><p class="copyright">Whizlabs Copyright (C) 2011. All Rights Reserved.</p></div>
<script language="javascript">
	if(document.getElementById("left-column")) {
	
	}
	else {
		document.getElementById('leftfooter').style.display='none';
		document.getElementById('rightfooter').style.display='none';
		document.getElementById('rightfooter2').style.display='none';
	}
</script>
  <div id="footerbottom">
    
 <center>
	<div style="border:0px solid #FFFFFF; font-size:11px; font-family:Arial, Helvetica, sans-serif; font-weight:bold; color:#000;">
		<br>
		<span><a href="http://www.whizlabs.com/scja/scja.html" title="SCJA Certification" style="text-decoration:none; color:#000;">SCJA Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scjp/scjp.html" title="SCJP Certification" style="text-decoration:none; color:#000;">SCJP Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scwcd/scwcd.html" title="SCWCD Certification" style="text-decoration:none; color:#000;">SCWCD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scbcd/scbcd.html" title="SCBCD Certification" style="text-decoration:none; color:#000;">SCBCD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scdjws/scdjws.html" title="SCDJWS Certification" style="text-decoration:none; color:#000;">SCDJWS Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scmad/scmad.html" title="SCMAD Certification" style="text-decoration:none; color:#000;">SCMAD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scea/scea.html" title="SCEA Certification" style="text-decoration:none; color:#000;">SCEA Certification</a></span>

		<br><br>
		<span><a href="http://www.whizlabs.com/otherpages/legal.html" alt="coming soon" style="text-decoration:none; color:#000;">Legal</a></span> |
		<span><a href="http://www.whizlabs.com/otherpages/policies.html" alt="coming soon" style="text-decoration:none; color:#000;">Policies</a></span> |
		<span><a href="http://www.whizlabs.com/otherpages/copyrights-and-trademarks.html" alt="coming soon" style="text-decoration:none; color:#000;"> Copyrights and Trademarks</a></span>
	</div>
	<br>
</center>
</div>
 </div>

<!--End - Display Buttons with their course prices in each moodle pages: Devesh M-->
<!--Footer links for each moodle pages-->


<!--Google Adwords Code Start: Devesh M-->
	<!--quiz/review.php--> 
	<!-- Google Code for Trial Test Reviewed Conversion Page --> 
	<script type="text/javascript">
	<!--
	var google_conversion_id = 1071861065;
	var google_conversion_language = "en";
	var google_conversion_format = "2";
	var google_conversion_color = "ffffff";
	var google_conversion_label = "YhFjCNjMogEQyZqN_wM"; var google_conversion_value = 0; //--> </script> <script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/conversion.js">
	</script><iframe name="google_conversion_frame" width="200" height="26" src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/saved_resource.htm" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no">&lt;img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1071861065/?frame=0&amp;random=1324321247053&amp;cv=7&amp;fst=1324321247053&amp;num=1&amp;fmt=2&amp;value=0&amp;label=YhFjCNjMogEQyZqN_wM&amp;bg=ffffff&amp;hl=en&amp;guid=ON&amp;u_h=1080&amp;u_w=1920&amp;u_ah=1080&amp;u_aw=1920&amp;u_cd=32&amp;u_his=16&amp;u_tz=-120&amp;u_java=true&amp;u_nplug=27&amp;u_nmime=117&amp;ref=http%3A//www.whizlabs.com/examprep/mod/quiz/review.php%3Fattempt%3D170804&amp;url=http%3A//www.whizlabs.com/examprep/mod/quiz/review.php%3Fattempt%3D170804%26showall%3Dtrue" /&gt;</iframe>
	<noscript>
	&lt;div style="display:inline;"&gt;
	&lt;img height="1" width="1" style="border-style:none;" alt=""
	src="http://www.googleadservices.com/pagead/conversion/1071861065/?label=YhF
	jCNjMogEQyZqN_wM&amp;amp;guid=ON&amp;amp;script=0"/&gt;
	&lt;/div&gt;
	</noscript>
<!--Google Adwords Code End : Devesh M-->

<!--OnTarget Code Start: Devesh M-->
<script language="JavaScript">
	var s_PageName = "OCPJP 6 - Exam Simulator: Practice Test IV";

			</script>

<!--End of OnTarget Code: Devesh M-->

<!-- Start of Google Analytics Code: Devesh M-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="./OCPJP 6 - Exam Simulator  Practice Test IV_files/ga.js" type="text/javascript"></script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-320509-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<!--End of Google Analytics Code: Devesh M-->



</body><span id="skype_highlighting_settings" display="none" autoextractnumbers="1"></span><object id="skype_plugin_object" location.href="http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170804&amp;showall=true" location.hostname="www.whizlabs.com" style="position: absolute; visibility: hidden; left: -100px; top: -100px; " width="0" height="0" type="application/x-vnd.skype.click2call.chrome.5.6.0"></object></html>